RE: Two variable dictionary comprehension

2017-04-04 Thread Deborah Swanson
Rob Gaddi wrote, on Tuesday, April 04, 2017 3:56 PM > > On 04/04/2017 03:34 PM, Deborah Swanson wrote: > > Terry Reedy wrote, on Tuesday, April 04, 2017 11:04 AM > >> > >> I am sure that this is because list comprehensions were once thr only > >> comprehensions and that the index was not updated

RE: Two variable dictionary comprehension

2017-04-04 Thread Deborah Swanson
Sorry I bailed on you last night, but you know it's bad when you can't read anymore. I read through this today and saw several things I really need to work with more, especially dicts, sets, generators and the zip function. I've used all of them in fairly typical forms, but it's the atypical ones

Re: Two variable dictionary comprehension

2017-04-04 Thread Rob Gaddi
On 04/04/2017 03:34 PM, Deborah Swanson wrote: Terry Reedy wrote, on Tuesday, April 04, 2017 11:04 AM On 4/3/2017 2:35 AM, Gregory Ewing wrote: Deborah Swanson wrote: Oh, come on. That's a fairly obscure citation in the docs, one that would take a good deal of experience and time reading

RE: Two variable dictionary comprehension

2017-04-04 Thread Deborah Swanson
Terry Reedy wrote, on Tuesday, April 04, 2017 11:04 AM > > On 4/3/2017 2:35 AM, Gregory Ewing wrote: > > Deborah Swanson wrote: > > > >> Oh, come on. That's a fairly obscure citation in the docs, > one that > >> would take a good deal of experience and time reading > through them to > >> know

Re: Two variable dictionary comprehension

2017-04-04 Thread Terry Reedy
On 4/3/2017 6:09 PM, Deborah Swanson wrote: Nathan Ernst wrote, on April 03, 2017 1:59 PM I was a bit surprised when I looked at the language reference for 3.6.x. I expected there'd be a direct link to comprehensions, but there's not. ... FWIW, If one was completely new to Python, even knowin

Re: Two variable dictionary comprehension

2017-04-04 Thread Terry Reedy
On 4/3/2017 2:35 AM, Gregory Ewing wrote: Deborah Swanson wrote: Oh, come on. That's a fairly obscure citation in the docs, one that would take a good deal of experience and time reading through them to know was there, Having said that, the index of the Python docs could be improved a bit in

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Thanks Steve for writing this, and I'll read it more carefully when my illness gives my mind back to me. I was actually a math major before I discovered computer science, and I had to progress beyond machine language and assembler before I found the subtle differences and more flexible boundaries

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Gregory Ewing wrote, on Monday, April 03, 2017 4:23 PM > > Deborah Swanson wrote: > > I'd > > imagine that the old Google would have returned a good 10 pages or > > more (probably a lot more) of urls containing the phrase "dict > > comprehension" or "dictionary comprehension". > > It still does

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Gregory Ewing wrote, on Monday, April 03, 2017 4:23 PM > > Deborah Swanson wrote: > > All my guesses were based on the > > single variable (the most common type) examples I found. I just didn't > > think of putting a colon after 'label', and found nothing to suggest > > that's what I should do.

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Thank you Nate, for all these sources to study. Python was very easy for me to learn in 2 online courses, but it's been all uphill since then. I've learned a lot and for that I'm grateful, but there's so much farther to go. I've appreciated our discussions, but I am in fact a very sick person and

Re: Two variable dictionary comprehension

2017-04-03 Thread Jerry Hill
On Mon, Apr 3, 2017 at 5:50 PM, Deborah Swanson wrote: > Ah, but did you actually try to use the proposed solutions on the two > stackoverflow pages? It's been several weeks now, but I did, and neither > of those two examples fit my situation, which is why I ended up writing > my own, and unsatisf

Re: Two variable dictionary comprehension

2017-04-03 Thread Larry Martell
On Mon, Apr 3, 2017 at 8:24 PM Dennis Lee Bieber wrote: > On Mon, 3 Apr 2017 11:48:38 -0700, "Deborah Swanson" > declaimed the following: > > >But, if Larry Page and Sergey Brin could tinker around in their dorm > >rooms (or wherever they lived then) and they made the first Google (the > >first

RE: Two variable dictionary comprehension

2017-04-03 Thread Steve D'Aprano
On Tue, 4 Apr 2017 03:27 am, Deborah Swanson wrote: > I'll admit that both dictionaries and comprehensions are still a little > bit fuzzy to me, especially when I get away from the common usages. This > could be a good exercise to clarify some of the fuzzy areas. As far as comprehensions go, how

Re: Two variable dictionary comprehension

2017-04-03 Thread Gregory Ewing
Deborah Swanson wrote: I'd imagine that the old Google would have returned a good 10 pages or more (probably a lot more) of urls containing the phrase "dict comprehension" or "dictionary comprehension". It still does, as far as I can see. I just googled for "dict comprehension", and the vast ma

Re: Two variable dictionary comprehension

2017-04-03 Thread Gregory Ewing
Deborah Swanson wrote: But, if Larry Page and Sergey Brin could tinker around in their dorm rooms (or wherever they lived then) and they made the first Google (the first search engine?) It wasn't the first web search engine. But it was the first one that not only worked, but *kept* working as

Re: Two variable dictionary comprehension

2017-04-03 Thread Gregory Ewing
Deborah Swanson wrote: All my guesses were based on the single variable (the most common type) examples I found. I just didn't think of putting a colon after 'label', and found nothing to suggest that's what I should do. Hmmm, I'm not sure what the docs could do to make that any clearer. The ke

Re: Two variable dictionary comprehension

2017-04-03 Thread Gregory Ewing
Deborah Swanson wrote: I'll admit that both dictionaries and comprehensions are still a little bit fuzzy to me, especially when I get away from the common usages. This could be a good exercise to clarify some of the fuzzy areas. If you're fuzzy about dictionaries in general, it might be a good

Re: Two variable dictionary comprehension

2017-04-03 Thread Nathan Ernst
No worries, Deborah. Python is by most measurements a relatively easy/simple language to learn, but there are always the dusty corners. If you've not already, I recommend going through the online Python tutorial in it's entirety ( https://docs.python.org/3/tutorial/index.html). After that, learn

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Nathan Ernst wrote, on April 03, 2017 1:59 PM > > I was a bit surprised when I looked at the language reference > for 3.6.x. I expected there'd be a direct link to > comprehensions, but there's not. > > You have to know what you're looking for: > > 6.2.5: List Displays > 6.2.6: Set Displays >

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Jerry Hill wrote, on April 03, 2017 1:48 PM > > On Mon, Apr 3, 2017 at 10:30 AM, Deborah Swanson > wrote: > > Regular updates as the docs are updated would be a good > idea too. It's > > obvious that today's Google isn't up to it, although it > occurs to me > > that I haven't tried Google's

Re: Two variable dictionary comprehension

2017-04-03 Thread Nathan Ernst
I was a bit surprised when I looked at the language reference for 3.6.x. I expected there'd be a direct link to comprehensions, but there's not. You have to know what you're looking for: 6.2.5: List Displays 6.2.6: Set Displays 6.2.7: Dictionary Displays And, then, click on the appropriate eleme

Re: Two variable dictionary comprehension

2017-04-03 Thread Jerry Hill
On Mon, Apr 3, 2017 at 10:30 AM, Deborah Swanson wrote: > Regular updates as the docs are updated would be a good idea too. It's > obvious that today's Google isn't up to it, although it occurs to me > that I haven't tried Google's site search on python.org. So, when you search google for the phr

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Rob Gaddi wrote, on April 03, 2017 10:38 AM > > On 04/03/2017 10:27 AM, Deborah Swanson wrote: > > Dennis Lee Bieber wrote, on April 03, 2017 9:35 AM > >> > >> On Mon, 3 Apr 2017 07:30:40 -0700, "Deborah Swanson" > >> declaimed the following: > >> > >>> > >>> Clearly there's more to be found in

Re: Two variable dictionary comprehension

2017-04-03 Thread Rob Gaddi
On 04/03/2017 10:27 AM, Deborah Swanson wrote: Dennis Lee Bieber wrote, on April 03, 2017 9:35 AM On Mon, 3 Apr 2017 07:30:40 -0700, "Deborah Swanson" declaimed the following: Clearly there's more to be found in nooks, crannies and byways in the docs than you'll get to from the given poin

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Dennis Lee Bieber wrote, on April 03, 2017 9:35 AM > > On Mon, 3 Apr 2017 07:30:40 -0700, "Deborah Swanson" > declaimed the following: > > > > >Clearly there's more to be found in nooks, crannies and > byways in the > >docs than you'll get to from the given pointers in the > index. Maybe it

RE: Two variable dictionary comprehension

2017-04-03 Thread Deborah Swanson
Gregory Ewing wrote, on April 02, 2017 11:35 PM > > Deborah Swanson wrote: > > > Oh, come on. That's a fairly obscure citation in the docs, one that > > would take a good deal of experience and time reading > through them to > > know was there, > > You seemed to know that there was something

Re: Two variable dictionary comprehension

2017-04-03 Thread Chris Green
Gregory Ewing wrote: > > Part of being a good programmer is knowing how to track > down the information you need! > A very *large* part of it! :-) > Having said that, the index of the Python docs could be > improved a bit in this area -- currently it only mentions > "list" under "comprehensio

Re: Two variable dictionary comprehension

2017-04-02 Thread Gregory Ewing
Deborah Swanson wrote: Oh, come on. That's a fairly obscure citation in the docs, one that would take a good deal of experience and time reading through them to know was there, You seemed to know that there was something called a "dict comprehension". Googling for "python 3 dict comprehension"

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote. on April 02, 2017 7:41 PM > > "Deborah Swanson" writes: > > > Chris Angelico wrote, on April 02, 2017 6:37 PM > > > > > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > > > > Maybe I'm having another "dumb day" [.] > > > > Well, wouldncha know it, I never tried using a col

Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson" writes: > Chris Angelico wrote, on April 02, 2017 6:37 PM > > > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > > > Maybe I'm having another "dumb day" […] > > Well, wouldncha know it, I never tried using a colon. That's what I > get for just trying to guess. Yes, guessi

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote, on April 02, 2017 6:38 PM > > "Deborah Swanson" writes: > > > It seems like this should be easy to rewrite as a dict > comprehension: > > > > records_idx = {} > > for idx, label in enumerate(records[0]): > > records_idx[label] = idx > > How about this:: > >

RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Chris Angelico wrote, on April 02, 2017 6:37 PM > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson > wrote: > > It seems like this should be easy to rewrite as a dict > comprehension: > > > > records_idx = {} > > for idx, label in enumerate(records[0]): > > records_idx[label]

Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson" writes: > It seems like this should be easy to rewrite as a dict comprehension: > > records_idx = {} > for idx, label in enumerate(records[0]): > records_idx[label] = idx How about this:: records_idx = { label: idx for (idx, label) in enumer

Re: Two variable dictionary comprehension

2017-04-02 Thread Chris Angelico
On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson wrote: > It seems like this should be easy to rewrite as a dict comprehension: > > records_idx = {} > for idx, label in enumerate(records[0]): > records_idx[label] = idx > > Maybe I'm having another "dumb day", or maybe I've just bee