Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26366

RE: why the different output in Eclipse and Python Shell?

From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
Subject RE: why the different output in Eclipse and Python Shell?
Date 2012-08-01 15:26 +0000
References <CAEMsKDuUV9K0r3da2rvZVenMdFMvePSbHoK5NAa-t6gkBgQzQg@mail.gmail.com> <5018FFEF.3000203@davea.name>
Newsgroups comp.lang.python
Message-ID <mailman.2834.1343834830.4697.python-list@python.org> (permalink)

Show all headers | View raw


> > 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)

I think you mean
print "dict is", repr(dict.fromkeys(['China','America']))

Otherwise you are just printing the repr of the dict type
and not the dictionary created. I would really store the output and
then print it.

d = dict.fromkeys(['China','America'])
print "dict is", d

Ramit

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: why the different output in Eclipse and Python Shell? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-08-01 15:26 +0000

csiph-web