a.index(float('nan')) fails

2012-10-25 Thread mamboknave
>>> a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> a [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> a.index(float('nan')) Traceback (most recent call last): File "", line 1, in ValueError: list.index(x): x not in list That means, the function .index() cannot detect nan values. It happens

Re: a.index(float('nan')) fails

2012-10-25 Thread mamboknave
On Thursday, October 25, 2012 7:16:02 PM UTC-7, Cameron Simpson wrote: Of course!! How could I get into that trap?? Thanks to you & to Terry -- http://mail.python.org/mailman/listinfo/python-list

global vars across modules

2012-04-22 Thread mamboknave
I need to use global var across files/modules: # file_1.py a = 0 def funct_1() : a = 1 # a is global print(a) # file_2.py from file_1 import * def main() : funct_1() a = 2 # a is local, it's not imported print(a) Here above 'a' is not imported from file_1

Re: global vars across modules

2012-04-22 Thread mamboknave
On Sunday, April 22, 2012 12:48:23 PM UTC-7, Roy Smith wrote: > Answer 1: You can't. > > Answer 2: You might want to look at thread local storage > (http://docs.python.org/library/threading.html#threading.local). > > Answer 3: Are you sure you really want to do this? Thanks! Here is what I

Sorting (deeply) nested lists

2013-03-02 Thread mamboknave
I cannot resolve this on my own. Need help, please... nestedTuples = [ [ (L0t0e0, L0t0e1, L0t0e2), (L0t1e0, 2, L0t1e2), (L0t2e0, L0t2e1, L0t2e2) ], [ (L1t0e0, L1t0e1, L1t0e2), (L1t1e0, 0, L1t1e2), (L1t2e0, L1t2e1, L1t2e2) ], [ (L2t0e0, L2t0e1, L2t0e2), (L2t1e0, 1, L2t1e2), (L2t2e0, L2t2e1, L2t2e2)

Re: Sorting (deeply) nested lists

2013-03-02 Thread mamboknave
On Saturday, March 2, 2013 9:36:43 AM UTC-8, Peter Otten wrote: > > You can also write this as > > namedTuples.sort(key=lambda item: item[1][1]) > That's exactly what I did before and got "IndexError: list index out of range". So, I thought my lambda was wrong and posted here. Now, having seen