[Tutor] File transfer

Corey Richardson kb1pkl at aim.com
Sun Oct 31 17:10:15 CET 2010



On 10/31/2010 12:06 PM, Chris King wrote:
> On 10/31/2010 12:03 PM, Corey Richardson wrote:
>>
>>
>> On 10/31/2010 11:51 AM, Chris King wrote:
>>> On 10/30/2010 10:08 PM, Corey Richardson wrote:
>>>> If you can send a list, have the list [name, data] where name is 
>>>> the file name and data is the raw binary of the file, contained in 
>>>> a string.
>>>>
>>>> On 10/30/2010 9:11 PM, Chris King wrote:
>>>>>  Dear Tutors,
>>>>>     How would I send a file from one computer to another. I have 
>>>>> modules which can send simple objects, such as dictionaries with 
>>>>> simple objects in it. They can't send files thou. Please help.
>>>>>
>>>>> Sincerely,
>>>>>     Me
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Tutor maillist  -Tutor at python.org
>>>>> To unsubscribe or change subscription options:
>>>>> http://mail.python.org/mailman/listinfo/tutor
>>> how do I get raw binary from a file, or preferably a folder?
>> In order to send a folder, you would have to zip it up using the 
>> zipfile module.http://docs.python.org/library/zipfile.html
>>
>> To read from a file, you open it, and then read() it into a string 
>> like this:
>> for line in file:
>>     string += string + file.readline()
>>
>> That is the basic concept, but it should carry you far.
> I don't think readline will work an image. How do you get raw binary 
> from a zip? Also make sure you do reply to the tutor list too, not 
> just me.
If you want me to reply to the whole list, try sending the message to 
the whole list. Readlines will not work for an image. You need to open 
the file with the "rb" flag, why don't you read more into file I/O? 
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101031/ef830512/attachment.html>


More information about the Tutor mailing list