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


Groups > comp.lang.python > #43636

Re: Process tuple contents on the fly

References <f51058c3-0e36-429c-85d9-365be82b548f@googlegroups.com> <20130415135013.58430065@bigbox.christie.dr>
From Barrett Lewis <musikal.fusion@gmail.com>
Date 2013-04-15 12:05 -0700
Subject Re: Process tuple contents on the fly
Newsgroups comp.lang.python
Message-ID <mailman.641.1366052737.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

>   d = {}
>   for key, d[key] in (("this",18), ("that",17), ("other",38)):
>     print key
>     do_something(d)
>

Why not use a dict comprehension?
d = {k:v for k,v in  (("this",18), ("that",17), ("other",38))}

I feel this is more straightforward and easier to read. the results are the
same however.

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


Thread

Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 11:25 -0700
  Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 13:50 -0500
  Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:05 -0700
  Re: Process tuple contents on the fly Peter Otten <__peter__@web.de> - 2013-04-15 21:07 +0200
  Re: Process tuple contents on the fly Tim Chase <python.list@tim.thechases.com> - 2013-04-15 14:10 -0500
  Re: Process tuple contents on the fly Barrett Lewis <musikal.fusion@gmail.com> - 2013-04-15 12:16 -0700
  Re: Process tuple contents on the fly MRAB <python@mrabarnett.plus.com> - 2013-04-15 20:29 +0100
  Re: Process tuple contents on the fly Tobiah <toby@tobiah.org> - 2013-04-15 13:35 -0700
    Re: Process tuple contents on the fly Michael Torrie <torriem@gmail.com> - 2013-04-15 15:16 -0600
    Re: Process tuple contents on the fly Gnarlodious <gnarlodious@gmail.com> - 2013-04-15 16:46 -0700

csiph-web