meta None?
Tripp Lilley
tripp at perspex.com
Mon Aug 21 00:57:01 EDT 2000
Continuing with the "what the hell is he /doing/, anyway?" theme, I'll
offer another distraction :)
I'd like to implement a meta-None class... that is, a class that behaves
like None regardless of what you subject it to:
1: print metaNone # displays 'None'
2: print metaNone( ) # displays 'None'
3: if metaNone is None: print "yes" # displays 'yes'
4: if metaNone( ) is None: print "yes" # displays 'yes'
and so forth.
I understand how to get behaviours 1, 2, and 4 by overloading __repr__
and __call__. How would I get behaviour 3? I haven't found anything in a
cursory search of my literature suggesting I can overload "is".
Thanks again!
--
Tripp Lilley * tripp at perspex.com *
http://stargate.eheart.sg505.net/~tlilley/
-----------------------------------------------------------------------------
"This whole textual substitution thing is pissing me off.
I feel like I'm programming in Tcl."
- Eric Frias, former roommate, hacking partner extraordinaire
More information about the Python-list
mailing list