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


Groups > comp.lang.python > #43835

Re: Working with lists within Dictionaries

References <CAFqGZRHSuNx=A67j-+mT0Ahv0hgzyZPOesozy5A4SJZs-n-f7g@mail.gmail.com>
Date 2013-04-19 00:38 +1000
Subject Re: Working with lists within Dictionaries
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.775.1366295908.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Apr 18, 2013 at 11:58 PM, inshu chauhan <insideshoes@gmail.com> wrote:
> segments.setdefault(reg_num, [])[point] += point

Not sure what your desired structure is. This is seeking to add the
point to something indexed by the point; perhaps you simply want to
append to the list itself?

segments.setdefault(reg_num, []).append(point)

ChrisA

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


Thread

Re: Working with lists within Dictionaries Chris Angelico <rosuav@gmail.com> - 2013-04-19 00:38 +1000

csiph-web