Andreas Waldenburger wrote:
On Sat, 13 Mar 2010 13:42:12 -0800 (PST) vsoler
vicente.so...@gmail.com wrote:
By the way, I suppose I am the OP. Since I am not an native English
speaking person, I do not know what it stands for. Perhaps you can
tell me.
Perhaps you can find out yourself:
On Sun, 14 Mar 2010 08:36:55 -0400 Steve Holden st...@holdenweb.com
wrote:
Andreas Waldenburger wrote:
On Sat, 13 Mar 2010 13:42:12 -0800 (PST) vsoler
vicente.so...@gmail.com wrote:
By the way, I suppose I am the OP. Since I am not an native English
speaking person, I do not know what
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose first element is the count, and the second is the sum. If a 2-
tuple contains a None value, it should be discarded.
The expected
On 13 Mar, 15:05, vsoler vicente.so...@gmail.com wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose first element is the count, and the second is the sum. If a 2-
tuple
On Mar 13, 9:05 am, vsoler vicente.so...@gmail.com wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose first element is the count, and the second is the sum. If a 2-
tuple
vsoler wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose first element is the count, and the second is the sum. If a 2-
tuple contains a None value, it should be
On 13 Mar, 15:28, Patrick Maupin pmau...@gmail.com wrote:
On Mar 13, 9:05 am, vsoler vicente.so...@gmail.com wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose first
On Mar 13, 8:28 am, Patrick Maupin pmau...@gmail.com wrote:
On Mar 13, 9:05 am, vsoler vicente.so...@gmail.com wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict where each key has an associated list
whose
On Mar 13, 9:13 am, ru...@yahoo.com wrote:
On Mar 13, 8:28 am, Patrick Maupin pmau...@gmail.com wrote:
On Mar 13, 9:05 am, vsoler vicente.so...@gmail.com wrote:
Say that m is a tuple of 2-tuples
m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
and I need to build a d dict
On Mar 13, 9:26 am, ru...@yahoo.com wrote:
That should be:
d = {}
for item in m:
key = item[0]; value = item[1]
if key is None or value is None: continue
if key not in dict:
d[key] = [1, value]
else:
d[key][0] += 1
d[key][1] += value
That's it.
On 13 mar, 18:16, ru...@yahoo.com wrote:
On Mar 13, 9:26 am, ru...@yahoo.com wrote: That should be:
d = {}
for item in m:
key = item[0]; value = item[1]
if key is None or value is None: continue
if key not in dict:
d[key] = [1, value]
else:
On Mar 13, 2:42 pm, vsoler vicente.so...@gmail.com wrote:
By the way, I suppose I am the OP. Since I am not an native English
speaking person, I do not know what it stands for. Perhaps you can
tell me.
OP means Original Poster (the person who started the discussion)
or sometimes Original
On Sat, 13 Mar 2010 13:42:12 -0800 (PST) vsoler
vicente.so...@gmail.com wrote:
By the way, I suppose I am the OP. Since I am not an native English
speaking person, I do not know what it stands for. Perhaps you can
tell me.
Perhaps you can find out yourself:
using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster. Is there a better idiom that the code below to create
an ordered dict from an unordered list
can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster
On Mon, Feb 22, 2010 at 10:32 AM, Bryan bryanv...@gmail.com wrote:
unorderedDict = {}
for thing in unorderedList:
if thing.id in unorderedDict:
UpdateExistingValue(unorderedDict[thing.id])
else:
CreateNewValue(unorderedDict[thing.id])
dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster. Is there a better idiom that the code below to create
an ordered dict from an unordered
avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster
. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster
just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster. Is there a better idiom that the code below to create
. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster
? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster. Is there a better idiom that the code below to create
an ordered dict from an unordered
avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster
On 22 Feb, 21:29, Bryan bryanv...@gmail.com wrote:
Sorry about the sorted != ordered mix up. I want to end up with a
*sorted* dict from an unordered list. *Sorting the list is not
practical in this case.* I am using python 2.5, with an ActiveState
recipe for an OrderedDict.
Why does the
loop. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become
think of a way to build
the ordered dict while going through the original loop. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure
create an ordered dict. I can't think of a way to build
the ordered dict while going through the original loop. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building
can't think of a way to build
the ordered dict while going through the original loop. Is there a
way I can avoid creating the first unordered dict just to get the
ordered dict? Also, I am using pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure
pop(k) to retrieve the values from the
unordered dict while building the ordered one because I figure that as
the values are removed from the unordered dict, the lookups will
become faster. Is there a better idiom that the code below to create
an ordered dict from an unordered list
On 2/22/2010 4:29 PM, Bryan wrote:
Sorry about the sorted != ordered mix up. I want to end up with a
*sorted* dict from an unordered list. *Sorting the list is not
practical in this case.* I am using python 2.5, with an ActiveState
recipe for an OrderedDict.
Have you looked at this:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
header.
For example:
d={ (u'a',u'x'):1.0, (u'a',u'y'): 7.0, (u'b',u'y'):8.0 }
As you
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
header.
For example:
d={ (u'a',u'x'):1.0, (u'a',u'y'): 7.0,
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
vsoler wrote:
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None, 8.0))
I need to build a dictionary that has, as key, the row and column
On Feb 20, 8:54 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
On Feb 20, 7:00 pm, MRAB pyt...@mrabarnett.plus.com wrote:
vsoler wrote:
Hello everyone!
I have a tuple of tuples, coming from an Excel range, such as this:
((None, u'x', u'y'),
(u'a', 1.0, 7.0),
(u'b', None,
35 matches
Mail list logo