Re: Want to reduce steps of an operation with dictionaries

2006-10-26 Thread Michael Naunton
It does not look nice at all, mainly because you are asking either asking the question upside down, or not providing enough information. If a and b are of vastly different sizes, say so. Otherwise, think about your algorithm, and realize you are asking for things in b if they exist in a: > dict

Re: Want to reduce steps of an operation with dictionaries

2006-10-25 Thread pretoriano_2001
Mike: Many thanks for your solution. It looks really nice. Mike Erickson wrote: > * [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > > Hello: > > I have next dictionaries: > > a={'a':0, 'b':1, 'c':2, 'd':3} > > b={'a':0, 'c':1, 'd':2, 'e':3} > > I want to put in a new dictionary named c all the ke

Re: Want to reduce steps of an operation with dictionaries

2006-10-25 Thread pretoriano_2001
James: Your solution works for me, many, many thanks for your help and many thanks for the time, teaching and reflections I received from all the guys that participated in this thread. James Stroud wrote: > [EMAIL PROTECTED] wrote: > > Hello: > > I have next dictionaries: > > a={'a':0, 'b':1, 'c'

Eschew obfuscation (was: Want to reduce steps of an operation with dictionaries)

2006-10-24 Thread Ben Finney
Fredrik Lundh <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > >> How can I do this with one line of instruction? > > > > As a general piece of advice, [...] Don't try to compress things > > into fewer lines unless that actually makes it clearer to read. > > I was about to suggest adding some

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Fredrik Lundh
Ben Finney wrote: >> How can I do this with one line of instruction? > > Why one line? > > As a general piece of advice, try writing dumb, obvious code that > actually does the transformation you want, and then let us see > that. Don't try to compress things into fewer lines unless that > actual

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Ben Finney
[EMAIL PROTECTED] writes: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. The result I want is: > c={'a':0, 'c':1, 'd':2} Okay, it seems that what you

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Mike Erickson
* [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > Hello: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. The result I want is: > c={'a':0, 'c':1, 'd':2}

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Steve Holden
Carl Banks wrote: > Steve Holden wrote: > >>[EMAIL PROTECTED] wrote: >> >>>Hello: >>>I have next dictionaries: >>>a={'a':0, 'b':1, 'c':2, 'd':3} >>>b={'a':0, 'c':1, 'd':2, 'e':3} >>>I want to put in a new dictionary named c all the keys that are in b >>>and re-sequence the values. The result I wan

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread James Stroud
Ben Finney wrote: > [EMAIL PROTECTED] writes: > > >>I have next dictionaries: >>a={'a':0, 'b':1, 'c':2, 'd':3} >>b={'a':0, 'c':1, 'd':2, 'e':3} >>I want to put in a new dictionary named c all the keys that are in b >>and re-sequence the values. > > > They never had a sequence, so you can't "re-

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Carl Banks
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > Hello: > > I have next dictionaries: > > a={'a':0, 'b':1, 'c':2, 'd':3} > > b={'a':0, 'c':1, 'd':2, 'e':3} > > I want to put in a new dictionary named c all the keys that are in b > > and re-sequence the values. The result I want is: > > c={'a':0,

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hello: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. The result I want is: > c={'a':0, 'c':1, 'd':2} > How can I do this wi

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Carl Banks
[EMAIL PROTECTED] wrote: > Hello: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. The result I want is: > c={'a':0, 'c':1, 'd':2} > How can I do this w

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Gabriel Genellina
At Tuesday 24/10/2006 21:29, [EMAIL PROTECTED] wrote: a={'a':0, 'b':1, 'c':2, 'd':3} b={'a':0, 'c':1, 'd':2, 'e':3} I want to put in a new dictionary named c all the keys that are in b and re-sequence the values. The result I want is: c={'a':0, 'c':1, 'd':2} How can I do this with one line of in

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Ben Finney
[EMAIL PROTECTED] writes: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. They never had a sequence, so you can't "re-sequence" them. You have not, p

Re: Want to reduce steps of an operation with dictionaries

2006-10-24 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Hello: > I have next dictionaries: > a={'a':0, 'b':1, 'c':2, 'd':3} > b={'a':0, 'c':1, 'd':2, 'e':3} > I want to put in a new dictionary named c all the keys that are in b > and re-sequence the values. The result I want is: > c={'a':0, 'c':1, 'd':2} > How can I do this wi

Want to reduce steps of an operation with dictionaries

2006-10-24 Thread pretoriano_2001
Hello: I have next dictionaries: a={'a':0, 'b':1, 'c':2, 'd':3} b={'a':0, 'c':1, 'd':2, 'e':3} I want to put in a new dictionary named c all the keys that are in b and re-sequence the values. The result I want is: c={'a':0, 'c':1, 'd':2} How can I do this with one line of instruction? I attempted