Re: OrderedDict with kwds

2017-04-22 Thread Ben Finney
Albert-Jan Roskam writes: > The basic problem is that kwds is a regular, unordered dict […] (Albert, you are probably aware that the above passage is not what you wrote. But your message shows it indistinguishable from your other text. Please teach your email client to compose quoted material u

Re: OrderedDict with kwds

2017-04-22 Thread Ben Finney
INADA Naoki writes: > On Sat, Apr 22, 2017 at 10:41 PM, Ben Finney > wrote: > > So, I would recommend continuing to code as though ‘dict’ is not > > ordered, at least until a Python version is released with a clear > > statement that ordering can be relied upon. > > While dict's order is implem

Re: OrderedDict with kwds

2017-04-22 Thread INADA Naoki
On Sat, Apr 22, 2017 at 10:41 PM, Ben Finney wrote: > INADA Naoki writes: > >> From Python 3.6, keyword arguments are ordered. So the docstring is >> outdated. > > (Thank you, Inada-san, for the implementation!) > > The announcement of the change specifies that we should not rely on > ordered ‘di

Re: OrderedDict with kwds

2017-04-22 Thread Albert-Jan Roskam
From: eryk sun Sent: Saturday, April 22, 2017 7:59 AM To: Python Main Cc: Albert-Jan Roskam Subject: Re: OrderedDict with kwds   On Fri, Apr 21, 2017 at 6:08 PM, Albert-Jan Roskam wrote: > Would the insertion order be preserved if the last line were to be > replaced with: >

Re: OrderedDict with kwds

2017-04-22 Thread Ben Finney
INADA Naoki writes: > From Python 3.6, keyword arguments are ordered. So the docstring is > outdated. (Thank you, Inada-san, for the implementation!) The announcement of the change specifies that we should not rely on ordered ‘dict’: The order-preserving aspect of this new implementation i

Re: OrderedDict with kwds

2017-04-22 Thread Peter Otten
Albert-Jan Roskam wrote: > For regular dicts I like to use the dict() function because the code is > easier to write and read. But OrderedDict() is not equivalent to dict(): > In the docstring of collections.OrderedDict it says "keyword arguments are > not recommended because their insertion order

Re: OrderedDict with kwds

2017-04-22 Thread INADA Naoki
On Sat, Apr 22, 2017 at 3:08 AM, Albert-Jan Roskam wrote: > For regular dicts I like to use the dict() function because the code is > easier to write and read. But OrderedDict() is not equivalent to dict(): > In the docstring of collections.OrderedDict it says "keyword arguments are > not recomm

Re: OrderedDict with kwds

2017-04-22 Thread eryk sun
On Fri, Apr 21, 2017 at 6:08 PM, Albert-Jan Roskam wrote: > Would the insertion order be preserved if the last line were to be > replaced with: > > if kwds: > for k, v in kwds.items(): > self[k] = v > if args: > self.__update(*args) # no **kwds! The basic problem is that kwds is

OrderedDict with kwds

2017-04-22 Thread Albert-Jan Roskam
For regular dicts I like to use the dict() function because the code is easier to write and read. But OrderedDict() is not equivalent to dict(): In the docstring of collections.OrderedDict it says "keyword arguments are not recommended because their insertion order is arbitrary" (https://github.