[Tutor] unexpected list entry

surya k suryak at live.com
Fri Dec 2 16:52:22 CET 2011


One more thing I want to mention..
I think there is a problem in the IDE itself. I have faced some problems 
with this IDE before... (Not with this)

Could you please tell me a free python IDE (No Eclipse/ Netbeans)

--------------------------------------------------
From: "Dave Angel" <d at davea.name>
Sent: Friday, December 02, 2011 7:43 PM
To: "surya k" <suryak at live.com>
Cc: "Python Tutor" <tutor at python.org>
Subject: Re: [Tutor] unexpected list entry

> On 12/02/2011 08:49 AM, surya k wrote:
>> Hi,
>>
>> Just take a look at this small code.. I am just taking a string as input 
>> and assigning it as a list.
>> But I am finding an unexpected entry in the list.. Why this is happening?
>>
>> I am using PyScripter IDE.
>>
>>
>> code :
>>
>>
>> #!/usr/bin/env python
>>
>> def main():
>>      pass
>>
>> if __name__ == '__main__':
>>      main()
>>
>> print "Flames: "
>> name1 = raw_input('enter name 1')
>>
>> ListName1 = list(name1)
>> print name1
>> print ListName1
>>
>>
>> Output:
>>
>> Flames:
>> foo
>> [u'f', u'o', u'o']
>>
>>
>> Observe the last line.. it isn't showing [ 'f', 'o', 'o']
>> Why is that "u" coming in the middle from no where ??
>>
> The u""  notation just says it's a unicode string.  No more confusing than 
> the [] meaning it's a list.  Neither is the content of the object, just 
> showing you textually what the type is.  You should also print 
> repr(name1) to see if it is likewise a unicode string.  I presume it's 
> already unicode when returned by raw_input().
>
> My puzzle is how you got unicode strings, if you've shown your entire 
> program.   In Python3, all strings are unicode, so it wouldn't bother to 
> say so.  Besides, your code has a syntax error in it, if it's supposed to 
> be Python 3.x
>
> You probably need to identify your particular version of Python, and the 
> platform (OS) you're running it on.
>
> But it could be affected by your IDE (Pyscripter), or by a site.py or 
> other implicitly loaded module.
> You can check for the former by running the script from a command shell.
>
> -- 
>
> DaveA
>
> 


More information about the Tutor mailing list