Is it possible (and wise) to extend the None-type ?
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Wed Nov 26 19:47:51 EST 2008
On Wed, 26 Nov 2008 13:24:25 -0800, Jason Scheirer wrote:
> On Nov 26, 11:40 am, Terry Reedy <tjre... at udel.edu> wrote:
>> def Skipper(object):
>> def Skip(): pass
>> skipper = Skipper()
>>
>> def _On_Menu_File_Open ( self, event = skipper ):
>> event.Skip ()
>>
>> etc.
>
> I think this methods works best, but quite frankly, if a method is only
> two lines long, then you've likely got a code smell and no amount of
> over-design is going to cover for it.
That's nuts. Methods should be as short as they need to be. Except in
code where performance is *REALLY* a bottleneck, you should be factoring
out common code into methods, even if the common code is only one or two
lines. Sometimes the entire class is just two lines:
class MyModuleError(ValueError):
pass
It's unusual for something to be that short, simply because you can't do
much in just two lines (especially if you are counting the method
definition as one of those lines) but something isn't wrong just because
it's short.
--
Steven
More information about the Python-list
mailing list