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


Groups > comp.lang.python > #81987

Re: dict turn to list at runtime unexpected!!!

From dieter <dieter@handshake.de>
Subject Re: dict turn to list at runtime unexpected!!!
Date 2014-12-05 08:42 +0100
References <e5012cb1-1820-4380-8e84-e8620481cc42@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.16614.1417765507.18130.python-list@python.org> (permalink)

Show all headers | View raw


telnetgmike@gmail.com writes:

> Why the following code gives me errors??? And why the print statement run 2 times? I'll be appreciated your helps, thanks,
> addrnum_dict = {'a':1,'b':2}
> def orderaddrtimes():
>     global addrnum_dict
>     print type(addrnum_dict)
>
>     addrnum_dict = sorted(addrnum_dict.iteritems(), key=lambda d:d[1], reverse = True)

"sorted" returns a list.

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


Thread

dict turn to list at runtime unexpected!!! telnetgmike@gmail.com - 2014-12-04 22:56 -0800
  Re: dict turn to list at runtime unexpected!!! telnetgmike@gmail.com - 2014-12-04 23:37 -0800
  Re: dict turn to list at runtime unexpected!!! dieter <dieter@handshake.de> - 2014-12-05 08:42 +0100
  Re: dict turn to list at runtime unexpected!!! Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-12-05 12:43 -0500

csiph-web