Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-11 Thread russ . pobox
Just try this in the interpreter and see. for key, value in sorted(months.items(), key=lambda x:x[1]): print %s %s % (value, key) -- http://mail.python.org/mailman/listinfo/python-list

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Νικόλαος Κούρας
Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted( months.keys() ): print(''' option value=%s %s /option ''' % (months[key], key) ) this in fact works, it sorts the dict by its keys() was mistaken before but

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted( months.keys() ): print(''' option value=%s %s /option ''' % (months[key], key) ) this in fact works, it sorts

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Νικόλαος Κούρας
Τη Δευτέρα, 10 Ιουνίου 2013 4:14:33 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted( months.keys() ): print('''

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Νικόλαος Κούρας
Τη Δευτέρα, 10 Ιουνίου 2013 4:14:33 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted( months.keys() ): print('''

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Νικόλαος Κούρας
Since dict.keys() return a list of the keys in the dict and the keys are associated with the dict's values why doesnt it work the other way around too? I'm talking about this: [code] for key in sorted( months.keys() ): print(''' option value=%s %s /option

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread Ulrich Eckhardt
Am 10.06.2013 15:37, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 4:14:33 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: Am 10.06.2013 12:57, schrieb Νικόλαος Κούρας: Τη Δευτέρα, 10 Ιουνίου 2013 12:40:01 μ.μ. UTC+3, ο χρήστης Ulrich Eckhardt έγραψε: for key in sorted(

Re: Reply to post 'Tryign to add a valkue to a set'

2013-06-10 Thread russ . pobox
for key, value in sorted(months.items(), key=lambda x:x[1]): print('\toption value%s%s/option'\n % (value, key)) Explanation: - - - - - - dict.items is a method associated with dicts just like dict.keys or dict.values, and returns a list of (key, value) pairs. sorted and some other