True
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Oct 20 06:09:44 EDT 2003
More information about the Python-list mailing list
Mon Oct 20 06:09:44 EDT 2003
- Previous message (by thread): True
- Next message (by thread): True
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
David Eppstein <eppstein at ics.uci.edu> wrote in news:eppstein- D286CF.08171519102003 at news.service.uci.edu: >> Then, what is the best way to write boolean operations for Python 2.1 so >> that it will be as 2.3+ ready as possible? > > I've been including the following at the start of some of my code: > > if 'True' not in globals(): > globals()['True'] = not None > globals()['False'] = not True > > My hope is that setting up True and False in this convoluted way will > allow it to continue to work in some future version where assignment to > builtins is disallowed. Since True will never be in globals unless you assign it there, you might as well just drop the if statement altogether. Also I fail to see what benefit you gain from the contorted assignment into the globals dictionary. Why not just write: True = not None False = not True It has the same effect overall. If you want to avoid hiding the builtin True and False, then use try..catch to detect them. -- 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?
- Previous message (by thread): True
- Next message (by thread): True
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list