Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84111

Re: Concerning Dictionaries and += in Python 2.x

From Peter Otten <__peter__@web.de>
Subject Re: Concerning Dictionaries and += in Python 2.x
Date 2015-01-21 09:59 +0100
Organization None
References <bc9e302a-356c-4223-9c25-6a8003db48e6@googlegroups.com> <m9nbrj$i7h$1@dont-email.me> <m9nork$s0k$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.17909.1421830806.18130.python-list@python.org> (permalink)

Show all headers | View raw


Peter Otten wrote:

> Denis McMahon wrote:

>>     sold = {k:0 for k in shopping.keys()}
> 
> There is also dict.from_keys()

Sorry, fromkeys():

>>> shopping = {'orange': 5, 'pear': 5, 'banana': 5, 'apple': 4}
>>> dict.fromkeys(shopping, 0)
{'banana': 0, 'orange': 0, 'apple': 0, 'pear': 0}

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:12 -0800
  Re: Concerning Dictionaries and += in Python 2.x Chris Angelico <rosuav@gmail.com> - 2015-01-20 11:21 +1100
    Re: Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:31 -0800
  Re: Concerning Dictionaries and += in Python 2.x MRAB <python@mrabarnett.plus.com> - 2015-01-20 00:27 +0000
  Re: Concerning Dictionaries and += in Python 2.x Luke Tomaneng <luketomaneng@gmail.com> - 2015-01-19 16:34 -0800
    Re: Concerning Dictionaries and += in Python 2.x Chris Angelico <rosuav@gmail.com> - 2015-01-20 11:46 +1100
  Re: Concerning Dictionaries and += in Python 2.x Dan Stromberg <drsalists@gmail.com> - 2015-01-19 16:54 -0800
  Re: Concerning Dictionaries and += in Python 2.x Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-21 05:01 +0000
    Re: Concerning Dictionaries and += in Python 2.x Peter Otten <__peter__@web.de> - 2015-01-21 09:43 +0100
      Re: Concerning Dictionaries and += in Python 2.x Denis McMahon <denismfmcmahon@gmail.com> - 2015-01-21 14:10 +0000
    Re: Concerning Dictionaries and += in Python 2.x Peter Otten <__peter__@web.de> - 2015-01-21 09:59 +0100

csiph-web