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 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> References: <777641c8-4928-4e49-832a-6a4a076628d1@o26g2000vby.googlegroups.com> 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: Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4893 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