interesting dict bug

Jeff McNeil jeff at jmcneil.net
Sat May 19 22:40:53 EDT 2007


Filename is a unicode string. See
http://www.diveintopython.org/xml_processing/unicode.html or
http://docs.python.org/tut/node5.html#SECTION005130000000000000000.

Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "string"
>>> unicode(s)
u'string'
>>>

You're not seeing the 'u' in the 'print filename' line as it isn't
actually part of the data.  You will see it in the 'print params2'
output, though, as I believe it relies on the string object's __repr__
function, which will include the unicode specifier.

-Jeff

On 5/19/07, Sick Monkey <sickcodemonkey at gmail.com> wrote:
> Here is a segment of some code that I have.
> CODE:
> --------------
>    print filename
>    params2 =
> {'filename':filename,'id3title':title,'id3artist':artist,'id3album':album,'id3year':year,'id3track':track,'id3genre':genre,'uname':username,'password':password,'filesToUpload':open(file,
> 'rb')}
>    print params2
> ----------------
> OUTPUT:
> 01.mp3
> {'password': u'XXX', 'id3year': '2002', 'id3album': 'album, 'id3title':
> 'Lose Yourself', 'filename': u'01.mp3', 'uname': u'', 'id3genre':
> 'Soundtrack', 'id3artist': 'Eminem', 'filesToUpload': <open file
> u'/Users/ozdon/Music/test2/01- eminemhhh.mp3', mode 'rb' at 0x106a5c0>,
> 'id3track': 'Unknown'}
> --------------
> Does anyone know how the random  " u' " is getting into the params2 or know
> how to around this?
>
> I am using Python 2.5 on MacOSX.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list