"thomas ct" wrote:

> what i was trying to say was how the various tuples behave..if i use
>
> file = ('file', filename, data)  #it gives me unicode error
> in this case I am using binary data..
>
> file = ('file', filename, 'data'*100)
> but the same filename works fine if i pass text data
>
> file = ('file', 'test.pdf', data)
>
> so if hardcode the file name /use
> filename=filename.encode("ascii") things work with binary data as well..
>
> I was wondering why..

if you mix a Unicode string with an 80-bit string, Python will try to
convert the 8-bit string to a Unicode string, which doesn't work if
the string contains characters outside the ASCII set.

you have to either encode the Unicode string into an 8-bit string, or
decode the non-ASCII string into a Unicode string.

</F>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to