Is it possible (and wise) to extend the None-type ?

Terry Reedy tjreedy at udel.edu
Wed Nov 26 14:40:49 EST 2008


Stef Mientki wrote:
> hello,
> 
> I've the idea that I always have a lot of useless code in my programs,
> like the next example.
> 
>  def _On_Menu_File_Open ( self, event = None ):
>    if event :
>     event.Skip ()
> 
> instead of
> 
>  def _O
> 
> So I would like to extend the None-type (if that's possible),
> with a dummy Skip() method.

def Skipper(object):
     def Skip(): pass
skipper = Skipper()

def _On_Menu_File_Open ( self, event = skipper ):
    event.Skip ()

etc.




More information about the Python-list mailing list