[issue432208] dict.keys() and dict.values() not new

2022-04-10 Thread admin
Change by admin : -- github: None -> 34609 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Wed, 24 Jul 2013 13:17:12 -0400, Terry Reedy wrote: On 7/24/2013 12:34 PM, Chris Angelico wrote: Side point: Why is iterating over a dict equivalent to .keys() rather than .items()? It feels odd that, with both options viable, the implicit version iterates over half the dict instead of

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Wed, 24 Jul 2013 17:59:43 -0700, Ethan Furman wrote: Repeat after me: In Python 2, d.keys() returns a list of keys, so if I want a list of keys in Python 3, call list explicitly list(d.keys()). Actually, I would recommend `list(d)`, which also works the same in both 2 and 3. Fair point.

Re: Python 3: dict dict.keys()

2013-07-25 Thread Chris Angelico
On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Dicts aren't sets, and don't support set methods: py d1 - d2 Traceback (most recent call last): File stdin, line 1, in module TypeError: unsupported operand type(s) for -: 'dict' and 'dict' I

Re: Python 3: dict dict.keys()

2013-07-25 Thread alex23
On 25/07/2013 4:31 AM, Ethan Furman wrote: 2) Hopefully learn something about when a view is useful. I haven't seeen this mentioned - forgive me if it's a repeat - but views are constant references to whichever set they represent. Python 2.7: dd = dict(a=1,b=2,c=3) keys = dd.keys()

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Wed, 24 Jul 2013 11:31:58 -0700, Ethan Furman wrote: On 07/24/2013 10:23 AM, Stefan Behnel wrote: Peter Otten, 24.07.2013 08:23: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? To me it looks like views

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Thu, 25 Jul 2013 16:02:42 +1000, Chris Angelico wrote: On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Dicts aren't sets, and don't support set methods: py d1 - d2 Traceback (most recent call last): File stdin, line 1, in module TypeError:

Re: Python 3: dict dict.keys()

2013-07-25 Thread Chris Angelico
On Thu, Jul 25, 2013 at 5:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: - Views support efficient (O(1) in the case of keys) membership testing, which neither iterkeys() nor Python2 keys() does. To save me the trouble and potential error of digging through the source code:

Re: Python 3: dict dict.keys()

2013-07-25 Thread Peter Otten
Chris Angelico wrote: On Thu, Jul 25, 2013 at 5:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: - Views support efficient (O(1) in the case of keys) membership testing, which neither iterkeys() nor Python2 keys() does. To save me the trouble and potential error of

Re: Python 3: dict dict.keys()

2013-07-25 Thread Chris Angelico
On Thu, Jul 25, 2013 at 5:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Jul 2013 16:02:42 +1000, Chris Angelico wrote: On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Dicts aren't sets, and don't support set methods:

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Thu, 25 Jul 2013 18:15:22 +1000, Chris Angelico wrote: On Thu, Jul 25, 2013 at 5:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Jul 2013 16:02:42 +1000, Chris Angelico wrote: On Thu, Jul 25, 2013 at 3:48 PM, Steven D'Aprano

Re: Python 3: dict dict.keys()

2013-07-25 Thread Chris Angelico
On Thu, Jul 25, 2013 at 7:44 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Jul 2013 18:15:22 +1000, Chris Angelico wrote: That's true, but we already have that issue with sets. What's the union of {0} and {0.0}? Python's answer: It depends on the order of the

Re: Python 3: dict dict.keys()

2013-07-25 Thread Johannes Bauer
On 25.07.2013 07:48, Steven D'Aprano wrote: Then you aren't looking very closely. d.keys() returns a set-like view into the dict, which is great for comparing elements: py d1 = dict.fromkeys([1, 2, 3, 4]) py d2 = dict.fromkeys([3, 4, 5, 6]) py d1.keys() d2.keys() # keys that are in both

Re: Python 3: dict dict.keys()

2013-07-25 Thread Ethan Furman
On 07/24/2013 11:01 PM, alex23 wrote: On 25/07/2013 4:31 AM, Ethan Furman wrote: 2) Hopefully learn something about when a view is useful. I haven't seeen this mentioned - forgive me if it's a repeat - but views are constant references to whichever set they represent. Python 2.7: dd =

Re: Python 3: dict dict.keys()

2013-07-25 Thread Ethan Furman
On 07/24/2013 10:48 PM, Steven D'Aprano wrote: On Wed, 24 Jul 2013 08:57:11 -0700, Ethan Furman wrote: My point is that in 2.x .keys() did something different from the dict, while in 3.x it appears to me that they are the same. Then you aren't looking very closely. Actually, I am. That's

Re: Python 3: dict dict.keys()

2013-07-25 Thread Steven D'Aprano
On Thu, 25 Jul 2013 20:34:23 +1000, Chris Angelico wrote: On Thu, Jul 25, 2013 at 7:44 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Jul 2013 18:15:22 +1000, Chris Angelico wrote: That's true, but we already have that issue with sets. What's the union of {0} and

Re: Python 3: dict dict.keys()

2013-07-25 Thread Chris Angelico
On Fri, Jul 26, 2013 at 12:57 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: [ snip lengthy explanation of sets ] The union operator ought to be symmetrical, a ∪ b should be identical to b ∪ a, but isn't. Another leaky abstraction. Right. I agree with all your theory, which

Re: Python 3: dict dict.keys()

2013-07-25 Thread Ian Kelly
On Thu, Jul 25, 2013 at 2:13 AM, Peter Otten __pete...@web.de wrote: Chris Angelico wrote: On Thu, Jul 25, 2013 at 5:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: - Views support efficient (O(1) in the case of keys) membership testing, which neither iterkeys() nor

RE: Python 3: dict dict.keys()

2013-07-25 Thread Prasad, Ramit
Terry Reedy wrote: On 7/24/2013 4:34 PM, Prasad, Ramit wrote: I am still not clear on the advantage of views vs. iterators. A1: Views are iterables that can be iterated more than once. Therefore, they can be passed to a function that re-iterates its inputs, or to multiple functions.

Re: Python 3: dict dict.keys()

2013-07-25 Thread Peter Otten
Ian Kelly wrote: On Thu, Jul 25, 2013 at 2:13 AM, Peter Otten __pete...@web.de wrote: Chris Angelico wrote: On Thu, Jul 25, 2013 at 5:04 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: - Views support efficient (O(1) in the case of keys) membership testing, which neither

Re: Python 3: dict dict.keys()

2013-07-25 Thread Ethan Furman
On 07/25/2013 09:11 AM, Prasad, Ramit wrote: Terry Reedy wrote: On 7/24/2013 4:34 PM, Prasad, Ramit wrote: I am still not clear on the advantage of views vs. iterators. A1: Views are iterables that can be iterated more than once. Therefore, they can be passed to a function that re-iterates

Re: Python 3: dict dict.keys()

2013-07-25 Thread Terry Reedy
On 7/25/2013 12:21 PM, Ethan Furman wrote: On 07/25/2013 09:11 AM, Prasad, Ramit wrote: Hmm, that is a change that makes some sense to me. Does the view get updated when dictionary changes or is a new view needed? I assume the latter. Nope, the former. That is a big advantage that the

Re: Python 3: dict dict.keys()

2013-07-24 Thread Peter Otten
Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr/lib/python3, and could not identify a single line where some_object.keys() wasn't either wrapped in a list (or set, sorted, max) call

Re: Python 3: dict dict.keys()

2013-07-24 Thread Oscar Benjamin
On Jul 24, 2013 7:25 AM, Peter Otten __pete...@web.de wrote: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr/lib/python3, and could not identify a single line where

Re: Python 3: dict dict.keys()

2013-07-24 Thread Neil Cerutti
On 2013-07-24, Peter Otten __pete...@web.de wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr/lib/python3, and could not identify a single line where some_object.keys() wasn't either wrapped

Re: Python 3: dict dict.keys()

2013-07-24 Thread Peter Otten
Oscar Benjamin wrote: On Jul 24, 2013 7:25 AM, Peter Otten __pete...@web.de wrote: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr/lib/python3, and could not identify a single

Re: Python 3: dict dict.keys()

2013-07-24 Thread Skip Montanaro
What do you mean? Why would you want to create a temporary list just to iterate over it explicitly or implicitly (set, sorted, max,...)? Because while iterating over the keys, he might also want to add or delete keys to/from the dict. You can't do that while iterating over them in-place. This

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ian Kelly
On Tue, Jul 23, 2013 at 8:11 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Basically, views are set-like, not list-like. The keys and items views are set-like. The values view is not. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ian Kelly
On Wed, Jul 24, 2013 at 8:58 AM, Skip Montanaro s...@pobox.com wrote: What do you mean? Why would you want to create a temporary list just to iterate over it explicitly or implicitly (set, sorted, max,...)? Because while iterating over the keys, he might also want to add or delete keys

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ethan Furman
On 07/24/2013 05:51 AM, Oscar Benjamin wrote: On Jul 24, 2013 7:25 AM, Peter Otten __pete...@web.de mailto:pete...@web.de wrote: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr

Re: Python 3: dict dict.keys()

2013-07-24 Thread Oscar Benjamin
On Jul 24, 2013 2:27 PM, Peter Otten __pete...@web.de wrote: Oscar Benjamin wrote: On Jul 24, 2013 7:25 AM, Peter Otten __pete...@web.de wrote: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I

Re: Python 3: dict dict.keys()

2013-07-24 Thread Chris Angelico
On Thu, Jul 25, 2013 at 1:57 AM, Ethan Furman et...@stoneleaf.us wrote: On 07/24/2013 05:51 AM, Oscar Benjamin wrote: What do you mean? Why would you want to create a temporary list just to iterate over it explicitly or implicitly (set, sorted, max,...)? You wouldn't. But you don't need

Re: Python 3: dict dict.keys()

2013-07-24 Thread Terry Reedy
On 7/24/2013 12:34 PM, Chris Angelico wrote: Side point: Why is iterating over a dict equivalent to .keys() rather than .items()? It feels odd that, with both options viable, the implicit version iterates over half the dict instead of all of it. Obviously it can't be changed now, even if

Re: Python 3: dict dict.keys()

2013-07-24 Thread Stefan Behnel
Chris Angelico, 24.07.2013 18:34: On Thu, Jul 25, 2013 at 1:57 AM, Ethan Furman wrote: On 07/24/2013 05:51 AM, Oscar Benjamin wrote: What do you mean? Why would you want to create a temporary list just to iterate over it explicitly or implicitly (set, sorted, max,...)? You wouldn't. But

Re: Python 3: dict dict.keys()

2013-07-24 Thread Stefan Behnel
Peter Otten, 24.07.2013 08:23: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? I just grepped through /usr/lib/python3, and could not identify a single line where some_object.keys() wasn't either wrapped

Re: Python 3: dict dict.keys()

2013-07-24 Thread Chris Angelico
On Thu, Jul 25, 2013 at 3:17 AM, Terry Reedy tjre...@udel.edu wrote: On 7/24/2013 12:34 PM, Chris Angelico wrote: Side point: Why is iterating over a dict equivalent to .keys() rather than .items()? It feels odd that, with both options viable, the implicit version iterates over half the dict

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ethan Furman
On 07/24/2013 10:23 AM, Stefan Behnel wrote: Peter Otten, 24.07.2013 08:23: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? To me it looks like views are a solution waiting for a problem. They reduce the API

Re: Python 3: dict dict.keys()

2013-07-24 Thread Stefan Behnel
Ethan Furman, 24.07.2013 20:31: On 07/24/2013 10:23 AM, Stefan Behnel wrote: Peter Otten, 24.07.2013 08:23: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? To me it looks like views are a solution waiting

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ethan Furman
On 07/24/2013 12:59 PM, Stefan Behnel wrote: I think the question is: how else would you implement an interface that doesn't restrict itself to returning a list? I mean, previously, the following was totally inefficient in terms of memory: value in d.values() It now avoids creating an

RE: Python 3: dict dict.keys()

2013-07-24 Thread Prasad, Ramit
Stefan Behnel wrote: Ethan Furman, 24.07.2013 20:31: On 07/24/2013 10:23 AM, Stefan Behnel wrote: Peter Otten, 24.07.2013 08:23: Ethan Furman wrote: So, my question boils down to: in Python 3 how is dict.keys() different from dict? What are the use cases? To me it looks like

Re: Python 3: dict dict.keys()

2013-07-24 Thread Christian Heimes
Am 24.07.2013 18:34, schrieb Chris Angelico: Side point: Why is iterating over a dict equivalent to .keys() rather than .items()? It feels odd that, with both options viable, the implicit version iterates over half the dict instead of all of it. Obviously it can't be changed now, even if

Re: Python 3: dict dict.keys()

2013-07-24 Thread Terry Reedy
On 7/24/2013 4:34 PM, Prasad, Ramit wrote: I am still not clear on the advantage of views vs. iterators. A1: Views are iterables that can be iterated more than once. Therefore, they can be passed to a function that re-iterates its inputs, or to multiple functions. They support 'x in view'

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ethan Furman
On 07/24/2013 01:34 PM, Prasad, Ramit wrote: I am still not clear on the advantage of views vs. iterators. What makes d.viewkeys() better than d.iterkeys()? Why did they decide not to rename d.iterkeys() to d.keys() and instead use d.viewkeys()? Is the iteration over a set operation on keys

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ethan Furman
On 07/23/2013 07:11 PM, Steven D'Aprano wrote: On Tue, 23 Jul 2013 18:16:08 -0700, Ethan Furman wrote: So now, in Python 3, .keys(), .values(), even .items() all return these 'view' thingies. And everything I thought I knew about when to use one or the other went out the window. Surely not.

Re: Python 3: dict dict.keys()

2013-07-24 Thread Ben Finney
Ethan Furman et...@stoneleaf.us writes: On 07/23/2013 07:11 PM, Steven D'Aprano wrote: On Tue, 23 Jul 2013 18:16:08 -0700, Ethan Furman wrote: And everything I thought I knew about when to use one or the other went out the window. Surely not. The fundamental behaviour of Python's data

Re: Python 3: dict dict.keys()

2013-07-24 Thread Steven D'Aprano
On Wed, 24 Jul 2013 08:57:11 -0700, Ethan Furman wrote: My point is that in 2.x .keys() did something different from the dict, while in 3.x it appears to me that they are the same. Then you aren't looking very closely. d.keys() returns a set-like view into the dict, which is great for

Python 3: dict dict.keys()

2013-07-23 Thread Ethan Furman
Back in Python 2.x days I had a good grip on dict and dict.keys(), and when to use one or the other. Then Python 3 came on the scene with these things called 'views', and while range couldn't be bothered, dict jumped up and down shouting, I want some! So now, in Python 3, .keys(), .values

Re: Python 3: dict dict.keys()

2013-07-23 Thread Steven D'Aprano
On Tue, 23 Jul 2013 18:16:08 -0700, Ethan Furman wrote: Back in Python 2.x days I had a good grip on dict and dict.keys(), and when to use one or the other. Then Python 3 came on the scene with these things called 'views', and while range couldn't be bothered, dict jumped up and down

[issue18510] dict.__contains__ and dict.keys().__contains__ raises exception instead of returning False

2013-07-22 Thread Ronald Oussoren
Ronald Oussoren added the comment: As mentioned on python-dev the current behavior seems sane. 1) Just like __getitem__ and __setitem__, __contains__ raises an exception when the key value cannot be used as a key (which normally is a programming error) 2) There are values that compare

[issue18510] dict.__contains__ and dict.keys().__contains__ raises exception instead of returning False

2013-07-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: There's no bug here. It is the way Python has worked for 23 years. -- nosy: +rhettinger versions: -Python 2.7, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18510

[issue18510] dict.__contains__ and dict.keys().__contains__ raises exception instead of returning False

2013-07-22 Thread Ronald Oussoren
Ronald Oussoren added the comment: I agree, and the thread on python-dev[1] also came to that conclusion, I'm therefore closing this issue. [1] http://code.activestate.com/lists/python-dev/123385/ -- resolution: - invalid stage: - committed/rejected status: open - closed

[issue18510] dict.__contains__ and dict.keys().__contains__ raises exception instead of returning False

2013-07-19 Thread Ethan Furman
Changes by Ethan Furman et...@stoneleaf.us: -- title: dict.__contains__ raises exception instead of returning False - dict.__contains__ and dict.keys().__contains__ raises exception instead of returning False ___ Python tracker rep

[issue13363] Many usages of dict.keys(), dict.values(), dict.items() when the iter version could be used

2011-11-06 Thread skreft
it to fix this? -- messages: 147199 nosy: skreft priority: normal severity: normal status: open title: Many usages of dict.keys(), dict.values(), dict.items() when the iter version could be used versions: Python 2.7 ___ Python tracker rep...@bugs.python.org

[issue13363] Many usages of dict.keys(), dict.values(), dict.items() when the iter version could be used

2011-11-06 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Thanks for you interest in improving Python. As noted in the response to one of your other issues, we generally do not do style cleanups just for the sake of style cleanups. In addition, our policy for current maintenance branches, like Python 2.7,

[issue13363] Many usages of dict.keys(), dict.values(), dict.items() when the iter version could be used

2011-11-06 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: skreft: since you were asking for a reason why the code looks the way it looks - the code in many cases predates the introduction of iterkeys and friends. I personally find the names iterkeys/itervalues/iteritems fairly ugly, and rather

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread John Yeung
On Apr 20, 1:23 am, Cameron Simpson c...@zip.com.au wrote: On 19Apr2010 21:31, alex23 wuwe...@gmail.com wrote: | Cameron Simpson c...@zip.com.au wrote: |   If items(), keys(), values(), iteritems(), iterkeys(), and |   itervalues() are called with no intervening modifications to the |  

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread Steven D'Aprano
On Mon, 19 Apr 2010 23:47:06 -0700, John Yeung wrote: On Apr 20, 1:23 am, Cameron Simpson c...@zip.com.au wrote: On 19Apr2010 21:31, alex23 wuwe...@gmail.com wrote: | Cameron Simpson c...@zip.com.au wrote: |   If items(), keys(), values(), iteritems(), iterkeys(), and |   itervalues() are

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread Dave Angel
Menghan Zheng wrote: Hello! Is it assured the following statement is always True? If it is always True, in which version, python2.x or python3.x? a = dict() ... assert(a.values == [a[k] for k in a.keys()]) -- ? Menghan Zheng No, it's never true. The assert

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread Carl Banks
On Apr 20, 1:13 am, Dave Angel da...@ieee.org wrote: Menghan Zheng wrote: Hello! Is it assured the following statement is always True? If it is always True, in which version, python2.x or python3.x? a = dict() ... assert(a.values == [a[k] for k in a.keys()]) -- ? Menghan

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread John Yeung
alex23 wrote: I stand corrected. Thanks Cameron. Cameron Simpson wrote: Oh, I was all ready to say what you said, but decided to check the docs myself first:-) John Yeung wrote: I am not too comfortable relying on it.  It feels fragile and implementationy to me, as I'm sure it

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-20 Thread alex23
Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: if you don't trust the language to behave correctly in this case: pairs = zip(d.values(), d.items()) what makes you think you can trust d.iteritems(), list comprehensions, or even tuple packing and unpacking? Because .iteritems()

dict.keys() and dict.values() are always the same order, is it?

2010-04-19 Thread Menghan Zheng
Hello! Is it assured the following statement is always True? If it is always True, in which version, python2.x or python3.x? a = dict() ... assert(a.values == [a[k] for k in a.keys()]) -- ? Menghan Zheng -- http://mail.python.org/mailman/listinfo/python-list

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-19 Thread Cameron Simpson
On 20Apr2010 11:03, Menghan Zheng menghan...@gmail.com wrote: | Is it assured the following statement is always True? | If it is always True, in which version, python2.x or python3.x? | | a = dict() | ... | assert(a.values == [a[k] for k in a.keys()]) | -- ? It is always true. At this URL:

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-19 Thread alex23
On Apr 20, 1:03 pm, Menghan Zheng menghan...@gmail.com wrote: Is it assured the following statement is always True? If it is always True, in which version, python2.x or python3.x? I believe its an implementation detail and should not be relied on. If you need consistent ordering, use an

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-19 Thread alex23
Cameron Simpson c...@zip.com.au wrote:   If items(), keys(), values(), iteritems(), iterkeys(), and   itervalues() are called with no intervening modifications to the   dictionary, the lists will directly correspond. This allows the   creation of (value, key) pairs using zip(): pairs =

Re: dict.keys() and dict.values() are always the same order, is it?

2010-04-19 Thread Cameron Simpson
On 19Apr2010 21:31, alex23 wuwe...@gmail.com wrote: | Cameron Simpson c...@zip.com.au wrote: |   If items(), keys(), values(), iteritems(), iterkeys(), and |   itervalues() are called with no intervening modifications to the |   dictionary, the lists will directly correspond. This allows the |

dict.keys() ?

2007-01-26 Thread bearophileHUGS
The PEP 3100: http://www.python.org/dev/peps/pep-3100/ says: Return iterators instead of lists where appropriate for atomic type methods (e.g. dict.keys(), dict.values(), dict.items(), etc.); iter* methods will be removed. Better: make keys(), etc. return views ala Java collections

Re: dict.keys() ?

2007-01-26 Thread George Sakkis
On Jan 26, 10:04 pm, [EMAIL PROTECTED] wrote: The PEP 3100:http://www.python.org/dev/peps/pep-3100/ says: Return iterators instead of lists where appropriate for atomic type methods (e.g. dict.keys(), dict.values(), dict.items(), etc.); iter* methods will be removed. Better: make keys