Ben Finney ben+python at benfinney.id.au writes:
In this case, I'll use ‘itertools.groupby’ to make a new sequence of
keys and values, and then extract the keys and values actually wanted.
Ah, yes, Zawinski revisited ... itertools.groupby is the new regex :-)
Certainly it might be clearer
So grateful! Thanks to all. The breadth of Python continues to amaze
me, as does your generosity.
(Relative clarity like relative beauty is in the eye of the
beholder,
and few parents have ugly children... fantastic!)
Brandon
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I am probably not thinking straight anymore about this problem. I
have a dictionary with tuple keys in the format (a, b, A, B) and float
values. I want to collect all the keys with identical (a, b...),
disregarding whatever (... A, B) might be. Specifically, I want to
sum the float
On Mon, Dec 14, 2009 at 9:49 PM, Brandon Devine your.mas...@gmail.com wrote:
Hi all,
I am probably not thinking straight anymore about this problem. I
have a dictionary with tuple keys in the format (a, b, A, B) and float
values. I want to collect all the keys with identical (a, b
Brandon Devine your.mas...@gmail.com writes:
I am probably not thinking straight anymore about this problem. I have
a dictionary with tuple keys in the format (a, b, A, B) and float
values. I want to collect all the keys with identical (a, b...),
disregarding whatever (... A, B) might
Brandon Devine your.mas...@gmail.com writes:
I am probably not thinking straight anymore about this problem. I
have a dictionary with tuple keys in the format (a, b, A, B) and float
values. I want to collect all the keys with identical (a, b...),
disregarding whatever (... A, B) might
Hi everbody
i am trying to print the dictionary values and tuple in a same line as below
print \t.join(dict[a].values())+'\t'+\t.join(b)
Error I get is the TypeError,
since i have misisng values in the dictionary. if i use exception i will
miss those
how should i print the data without
En Wed, 19 Mar 2008 08:16:52 -0300, Beema shafreen
[EMAIL PROTECTED] escribió:
i am trying to print the dictionary values and tuple in a same line as
below
print \t.join(dict[a].values())+'\t'+\t.join(b)
Error I get is the TypeError,
since i have misisng values in the dictionary
Erik Max Francis wrote:
bruno modulix wrote:
Err... don't you spot any useless code here ?-)
(tip: dict.items() already returns a list of (k,v) tuples...)
But it doesn't return a tuple of them. Which is what the tuple call
there does.
Of course, but the list-to-tuple conversion is not
I have a dictionary, and I want to convert it to a tuple,
that is, I want each key - value pair in the dictionary
to be a tuple in a tuple.
If this is the dictionary {1:'one',2:'two',3:'three'},
then I want this to be the resulting tuple:
((1,'one'),(2,'two'),(3,'three')).
I have been trying for
Odd-R. wrote:
I have a dictionary, and I want to convert it to a tuple,
that is, I want each key - value pair in the dictionary
to be a tuple in a tuple.
If this is the dictionary {1:'one',2:'two',3:'three'},
then I want this to be the resulting tuple:
((1,'one'),(2,'two'),(3,'three')).
It looks like you want tuple(d.iteritems())
d = {1: 'one', 2: 'two', 3: 'three'}
tuple(d.iteritems())
((1, 'one'), (2, 'two'), (3, 'three'))
You could also use tuple(d.items()). The result is essentially the
same. Only if the dictionary is extremely large does the difference
matter. (or if
On 28 Jun 2005 14:45:19 GMT, Odd-R. [EMAIL PROTECTED] wrote:
I have a dictionary, and I want to convert it to a tuple,
that is, I want each key - value pair in the dictionary
to be a tuple in a tuple.
If this is the dictionary {1:'one',2:'two',3:'three'},
then I want this to be the
Tim Williams (gmail) wrote:
(snip)
d = {1:'one',2:'two',3:'three'}
t = tuple([(k,v) for k,v in d.iteritems()])
Err... don't you spot any useless code here ?-)
(tip: dict.items() already returns a list of (k,v) tuples...)
--
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w
bruno modulix wrote:
Err... don't you spot any useless code here ?-)
(tip: dict.items() already returns a list of (k,v) tuples...)
But it doesn't return a tuple of them. Which is what the tuple call
there does.
--
Erik Max Francis [EMAIL PROTECTED] http://www.alcyone.com/max/
San Jose,
Erik Max Francis wrote:
bruno modulix wrote:
Err... don't you spot any useless code here ?-)
(tip: dict.items() already returns a list of (k,v) tuples...)
But it doesn't return a tuple of them. Which is what the tuple call
there does.
The useless code referred to was the list
Erik Max Francis wrote:
But it doesn't return a tuple of them. Which is what the tuple call
there does.
Yes, but I think he meant:
t = tuple(d.items())
--
Jeremy Sanders
http://www.jeremysanders.net/
--
http://mail.python.org/mailman/listinfo/python-list
bruno modulix [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Odd-R. wrote:
I have a dictionary, and I want to convert it to a tuple,
that is, I want each key - value pair in the dictionary
to be a tuple in a tuple.
If this is the dictionary {1:'one',2:'two',3:'three'},
then I
18 matches
Mail list logo