slow try statements in python?

Duncan Booth duncan at NOSPAMrcp.co.uk
Thu Feb 20 04:34:29 EST 2003


sjmachin at lexicon.net (John Machin) wrote in 
news:c76ff6fc.0302191309.4db8c0d9 at posting.google.com:

> I'm using Python 2.2 and it gives the following (expected as per the
> manual) results:
> 
>>>> d = {"foo":1, "bar": 2}
>>>> hasattr(d, "foo")
> 0
>>>> [hasattr(d, x) for x in d.keys()]
> [0, 0]
>>>> [hasattr(d, x) for x in dir(d)]
> [1, 1, 1, 1, etc etc]
>>>>
> 
> What are you using? Parrot 0.000001a ???
> 

No: brain failure!

That's what happens when you don't write unit tests for such complex code.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list