[TransWarp] Extending AbstractCommand

John Landahl john at landahl.org
Tue Oct 14 17:44:29 EDT 2003

Just made a slight improvement:

   class NullObject:
       def __getattr__(self, name):
           return None

   class OptionedCommand(AbstractCommand):

       def parsedOptions(self):
           if not self.parser:
               return (NullObject(), None)

So if for whatever reason no parser could be instantiated, subclasses can 
still test self.options.foo without blowing up.  Though on second thought 
I'm wondering if being explicit here (how?) might not be better, since the 
NullObject will produce different behavior than a real options object 
(which throws an AttributeError if a non-existant option is requested).

More information about the PEAK mailing list