Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'forgive': 0.05; 'instance.': 0.09; 'mess': 0.09; 'objects,': 0.09; 'strings.': 0.09; 'redundant,': 0.16; 'subject:dictionaries': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'separate': 0.22; 'header:User-Agent:1': 0.23; "haven't": 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'errors': 0.30; 'subject:list': 0.30; 'keys': 0.31; 'maintaining': 0.32; 'run': 0.32; 'another': 0.32; "i'd": 0.34; 'subject:from': 0.34; 'but': 0.35; 'two': 0.37; 'list': 0.37; 'mapping': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'users': 0.40; 'dave': 0.60; 'eventually': 0.60; 'received:74.208': 0.68; 'angel': 0.91 Date: Mon, 08 Dec 2014 08:35:23 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Nested dictionaries from a list ? References: <72066852-b4a1-4820-b52a-be56f68a0d7b@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:kNRDYgS1A8xlZV8I0scWDH8i1hXhyq2lVql2Npq6tfY rEPRVaGk1QdKs4uVqraLyXPgFbMCF99QlkTTNZIFMIbwt6PhWV rBBOnkpx6ofRUh5J++ODYkX7Jdj85nYTBkQZQDeGoNGrkIfVyx qqWOqQGa8+R4KZAdRVWChkbaEQgOfjqVnjD9mpk/jMHY9P02dc CoU1r/vgI7hxJbwcVqRAyDXQ0FdyNTfCy3BRke5QADCY6wvw6B A7xNTWyBubw9pCRSDgl4RbWHwLgDLDys+trI2rFRrnersiazJJ Eo/KODy5kj5g0CpsEpRJai43J/Hhvo55GmHkR0szboMQZ2MSUr Ag7BoEdJvThbFkJ95hgo= X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418045741 news.xs4all.nl 2912 [2001:888:2000:d::a6]:56663 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82123 On 12/07/2014 06:52 PM, Denis McMahon wrote: > On Sun, 07 Dec 2014 12:01:26 -0500, Dave Angel wrote: > >> On 12/07/2014 11:18 AM, Wacky wrote: > >>> I've a list of users .... > >> I haven't run this through the Python, so please forgive any typos. > >> users = [ .... >> mess = { .... > > users is redundant, as it's mess.keys() > > maintaining a separate list of users and having the users as the keys in > mess suggests redundancy, and the potential for errors if the two data > items get out of synch. Better imo to just have the data in one place. > Unless there's an order that wants to be retained. But I would change the list into a list of user objects, rather than of strings. And I'd know that eventually it would be a sparse list (as users come and go, and you don't want to reuse the indices). So it would be another dictionary mapping userid and User instance. -- DaveA