A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-list/1999-September/016629.html below:

keys and values lining up

keys and values lining upFred L. Drake, Jr. fdrake at acm.org
Mon Sep 27 22:06:01 EDT 1999
Nathan Clegg writes:
 > If d is a dict, am I guaranteed that d.keys() and d.values() will line up,
 > in proper order, if called successively with no modification in between? 
 > That is, is the following safe?
 > 
 > k,v = d.keys(), d.values()

  As someone pointed out, the implementation makes this happen modulo
thread interference.  I asked Guido about this a couple of years ago,
and he said he was willing to make that guarantee.
  Others have pointed out the .items() method; if that makes more
sense for your application, it is better because it avoids the
potentional for thread interference.  However, sometimes using the
individual methods is easier for the surrounding code if you really
want to separate lists, or if you want to end up with (value, key)
pairs (I think that's why I'd been interested in the question when I
asked Guido).


  -Fred

--
Fred L. Drake, Jr.	     <fdrake at acm.org>
Corporation for National Research Initiatives


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4