Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4893
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
| Newsgroups | comp.lang.python |
| Subject | Re: Dictionary Views -- good examples? [was Re: Python 3 dict question] |
| Date | Sat, 07 May 2011 21:09:09 +1200 |
| Lines | 19 |
| Message-ID | <92kghnFb37U1@mid.individual.net> (permalink) |
| References | <ded9dfa0-a031-4513-8751-7ff7bfd5dcc7@e8g2000vbz.googlegroups.com> <mailman.1262.1304711497.9059.python-list@python.org> <777641c8-4928-4e49-832a-6a4a076628d1@o26g2000vby.googlegroups.com> <BANLkTimo-LZShj2UwB0VEoRn2F14qtYgRg@mail.gmail.com> <mailman.1273.1304721478.9059.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net +iD8yTkSVGv8JdKrJb1LmAUQNaRVrDFNUsLqTX1/buIwFZfuEh |
| Cancel-Lock | sha1:r/mmEt0lUs4d7hC6jajgSI0qgEY= |
| User-Agent | Mozilla Thunderbird 1.0.5 (Macintosh/20050711) |
| X-Accept-Language | en-us, en |
| In-Reply-To | <mailman.1273.1304721478.9059.python-list@python.org> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4893 |
Show key headers only | View raw
Ethan Furman wrote:
> Ian Kelly wrote:
>
>> next(iter(myDict.items()))
>
> Which is becoming less elegant.
If you're doing this sort of thing a lot you can make
a little helper function:
def first(x):
return next(iter(x))
then you get to say
first(myDict.items())
--
Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Python 3 dict question dmitrey <dmitrey15@gmail.com> - 2011-05-06 12:40 -0700
Re: Python 3 dict question Chris Rebert <clp2@rebertia.com> - 2011-05-06 12:51 -0700
Re: Python 3 dict question dmitrey <dmitrey15@gmail.com> - 2011-05-06 12:57 -0700
Re: Python 3 dict question Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-06 14:48 -0600
Dictionary Views -- good examples? [was Re: Python 3 dict question] Ethan Furman <ethan@stoneleaf.us> - 2011-05-06 15:49 -0700
Re: Dictionary Views -- good examples? [was Re: Python 3 dict question] Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-07 21:09 +1200
Re: Dictionary Views -- good examples? [was Re: Python 3 dict question] Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-05-08 11:23 +0200
Re: Dictionary Views -- good examples? [was Re: Python 3 dict question] Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-06 18:23 -0600
Re: Dictionary Views -- good examples? [was Re: Python 3 dict question] Ethan Furman <ethan@stoneleaf.us> - 2011-05-10 10:18 -0700
Re: Python 3 dict question Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-06 14:02 -0600
Re: Python 3 dict question Rob Wolfe <rw@smsnet.pl> - 2011-05-06 22:46 +0200
Re: Python 3 dict question nirinA raseliarison <nirina.raseliarison@gmail.com> - 2011-05-06 14:18 -0700
Re: Python 3 dict question Raymond Hettinger <python@rcn.com> - 2011-05-10 10:25 -0700
csiph-web