Re: [Tutor] Handling Generator exceptions in Python 2.5

2009-06-19 Thread Joe Python
int results > > Vince > > > On Fri, Jun 19, 2009 at 8:55 AM, Joe Python wrote: > >> I have a generator as follows to do list calculations. >> >> *result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))]* >> >> The above generator, throws

[Tutor] Handling Generator exceptions in Python 2.5

2009-06-19 Thread Joe Python
I have a generator as follows to do list calculations. *result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))]* The above generator, throws '*ZeroDivisionError*' exception if ListA[i] = 0. Is there a way to say 'Don't divide by ListA[i] if its equal to 0 (within that statement)'.

[Tutor] Sorting Dictionary of Dictionary by certain Value

2008-09-23 Thread Joe Python
Hi Pythonistas, I have a large dictionary of dictionary (50,000+ keys) which has a structure as follows: DoD = { 'flintstones' : { 'husband' : "fred", 'pal' : "barney", 'income': 500, }, 'jetsons' : { 'husband' : "george", 'wif