On Thu, Aug 19, 2010 at 10:31 AM, Sahasranaman MS sah...@naman.ms wrote:
On Thursday 19 August 2010 07:08 AM, Kenneth Gonsalves wrote:
On Wed, 2010-08-18 at 10:28 -0700, Anand Shankar wrote:
I have no clues. Any inputs??
sort order of dictionary keys is not guaranteed. Only a list will
On Thu, Aug 19, 2010 at 10:31 AM, Sahasranaman MS sah...@naman.ms wrote:
On Thursday 19 August 2010 07:08 AM, Kenneth Gonsalves wrote:
On Wed, 2010-08-18 at 10:28 -0700, Anand Shankar wrote:
I have no clues. Any inputs??
sort order of dictionary keys is not guaranteed. Only a list will
Thanks a Ton to all. I got a mucher deeper insight than my question deserved!!!
Thanks once again
anand
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers
Hi All,
There really shouldn't be so much debate on the question asked.
Someone actually gave a direct and clear answer. I'm new at python and
his explanations were quite understandable.
As far as dictionaries are concerned, when you retrieve keys, there is
no guarantee of a particular order.
If
Here is a small script to sort the dictionary based on key/choice
a = {key3: 5 , key2: 8, key1: 2}
b = {key2: 7 , key1: 4, key3: 9}
c = {key1: 6 , key3: 1, key2: 1}
undecorated = [a, b, c] # how do you sort this list?
sort_on = key3
decorated = [(dict_[sort_on], dict_) for dict_ in [b]]
On Thu, Aug 19, 2010 at 10:26 AM, Dipo Elegbede delegb...@dudupay.comwrote:
Hi All,
There really shouldn't be so much debate on the question asked.
Someone actually gave a direct and clear answer. I'm new at python and
his explanations were quite understandable.
I'm sorry that you sensed a
Lots of good answers.
Warning: *this answer is ultra simplistic one to explain the implementation
succinctly*.
A little more from an implementation perspective dict operations usually
involve converting a dict into a hash. This hash is then converted into a
bucket. And sometimes when one gets
On Wed, Aug 18, 2010 at 10:58 PM, Anand Shankar anand_shan...@yahoo.com wrote:
During a tutorial python session with my colleagues I was presented with a
basic
question
d = {'apple':2,'banana':5, 'coke': 6}
print d.keys()
['coke', 'apple', 'banana']
Question is why does it not return
On 18 August 2010 22:58, Anand Shankar anand_shan...@yahoo.com wrote:
During a tutorial python session with my colleagues I was presented with a
basic
question
d = {'apple':2,'banana':5, 'coke': 6}
print d.keys()
['coke', 'apple', 'banana']
Question is why does it not return
Excellent responses so far.
Dictionaries are optimized for retrieving key/value pairs. And to achieve
that, it compromises on the order in which stuff is stored.
This and more is very nicely presented in the Pycon 2010 talk - The Mighty
Dictionary. Highly recommended.
On Wed, Aug 18, 2010 at 10:58 PM, Anand Shankar anand_shan...@yahoo.comwrote:
During a tutorial python session with my colleagues I was presented with a
basic
question
d = {'apple':2,'banana':5, 'coke': 6}
print d.keys()
['coke', 'apple', 'banana']
Question is why does it not return
On Thursday 19 August 2010 07:08 AM, Kenneth Gonsalves wrote:
On Wed, 2010-08-18 at 10:28 -0700, Anand Shankar wrote:
I have no clues. Any inputs??
sort order of dictionary keys is not guaranteed. Only a list will return
items in the same order as entered.
Python has an OrderedDict class from
12 matches
Mail list logo