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

Re: OrderedDict

2016-06-09 Thread silver0346
On Friday, May 20, 2016 at 7:15:38 AM UTC+2, silve...@gmail.com wrote: > On Wednesday, May 18, 2016 at 2:25:16 PM UTC+2, Peter Otten wrote: > > Chris Angelico wrote: > > > > > On Wed, May 18, 2016 at 7:28 PM, Peter Otten <__pete...@web.de> wrote: > > >> I don't see an official way to pass a custom

Re: OrderedDict

2016-05-19 Thread silver0346
On Wednesday, May 18, 2016 at 2:25:16 PM UTC+2, Peter Otten wrote: > Chris Angelico wrote: > > > On Wed, May 18, 2016 at 7:28 PM, Peter Otten <__pete...@web.de> wrote: > >> I don't see an official way to pass a custom dict type to the library, > >> but if you are not afraid to change its source co

Re: OrderedDict

2016-05-18 Thread Peter Otten
Chris Angelico wrote: > On Wed, May 18, 2016 at 7:28 PM, Peter Otten <__pete...@web.de> wrote: >> I don't see an official way to pass a custom dict type to the library, >> but if you are not afraid to change its source code the following patch >> will allow you to access the value of dictionaries

Re: OrderedDict

2016-05-18 Thread Chris Angelico
On Wed, May 18, 2016 at 7:28 PM, Peter Otten <__pete...@web.de> wrote: > I don't see an official way to pass a custom dict type to the library, > but if you are not afraid to change its source code the following patch > will allow you to access the value of dictionaries with a single entry as > d[

Re: OrderedDict

2016-05-18 Thread Peter Otten
silver0...@gmail.com wrote: > Hi all, > > I have a understanding problem with return values from xmltodict. > > I have a xml file. Content: > > > > > > > > > > With code > > __f_name = '' > with open(__f_name) as __fd: > __doc = xmltodict.parse(__fd.read()) > > __doc > >

Re: OrderedDict

2016-05-18 Thread Chris Angelico
On Wed, May 18, 2016 at 6:32 PM, wrote: > Hi all, > > I have a understanding problem with return values from xmltodict. > > I have a xml file. Content: > > > > > > > > > > > > > > > > > No prints __doc['profiles']['profile']['package'][0]['@package-id']: > > u'0964-gpg4

Re: OrderedDict / DIctComprehension

2012-10-29 Thread Christian
Too bad that's not (using python2.7) 'ordered_dict_generator' ((), {}) 1.089588 sec Anyway thanks for your hint! > Hi, > > > > is there a way building an OrderedDict faster? > > > > Thanks in advance > > Christian > > > > @timeit > > def ordered(n=10): > > d = OrderedDict() >

Re: OrderedDict / DIctComprehension

2012-10-29 Thread Terry Reedy
On 10/29/2012 8:36 AM, Christian wrote: Hi, is there a way building an OrderedDict faster? Thanks in advance Christian @timeit def ordered(n=10): d = OrderedDict() for i in xrange(n): d['key'+str(i)] = i return d try d = OrderedDict(['key'+str(i),i for i in xrange