<snip>
Alternative (if you *really* want to save the explicit test) is to
attach the behaviour modification to the *relevant* class:
class NonEvent(Event):
def do_nothing(self):
pass
skip = jump = hop = waltz = saunter = do_nothing
def __len__(self):
return 0
NON_EVENT = NonEvent()
del NonEvent
# later:
def amethod(self, event=NON_EVENT):
if event: # still works thanks to __len__ above
event.skip()
# now can avoid test, if desired
event.skip()
thanks guys, the Null, Dummy, Skipper, Nonevent class works great
HTH ... BTW, ever heard of PEP 8?
I guess Python is missing some kind of CSS ;-)
cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list