why the different output in Eclipse and Python Shell?

Dave Angel d at davea.name
Wed Aug 1 12:07:43 CEST 2012


On 08/01/2012 12:45 AM, levi nie wrote:
> my code in Eclipse:
>
> dict.fromkeys(['China','America'])
> print "dict is",dict
>
> output: dict is <type 'dict'>
>
> my code in Python Shell:
>
> dict.fromkeys(['China','America'])
>
> output:{'America': None, 'China': None}
>
> Output in Python Shell is what i wanna,but why not in Eclipse?
>
>

The Python Shell is an interactive debugger, and prints the repr() of
expressions that you don't assign anywhere.  I don't know Eclipse, but I
suspect what you want to do is something like:

print "dict is", repr(dict)



-- 

DaveA



More information about the Python-list mailing list