howto overload with a NOP (empty statement)
Jussi Salmela
tiedon_jano at hotmail.com
Sat Jan 6 09:34:35 EST 2007
Bruno Desthuilliers kirjoitti:
> Stef Mientki a écrit :
>> How should I overload / disable a method ?
>> In the example below I have defined the class "Power_Supply", derived
>> from baseclass "device".
>
> <off>
> Naming conventions are to use CamelCase for class names. So it would be
> better to name your classes 'PowerSupply' (no '_') and 'Device'. You're
> of course free to use whatever naming convention you want, including no
> convention at all, but Python relies *a lot* on naming conventions...
> </off>
Continuing with the style and idioms issues...
1. Don't leave a space between a function/method/class name and the
opening parenthesis, i.e. instead of:
def execute (self):
use:
def execute(self):
2. It seems to me that you indent your code with 2 spaces. If I'm wrong,
please ignore me. Otherwise: always use 4 spaces when indenting with spaces.
Following these and the numerous other guidelines (see
htpp://www.python.org/dev/peps/pep-0008/ for example) on Python style
you'll be making yourself and others a favor. When these coding
guidelines become your habit, it will be easier for you to read the code
of other Pythoners. This is important because a large part of learning
consists of reading the code of others.
And also vice versa: when you show your code to others, it will be
easier for them to concentrate on your problem when the idiosyncrasy of
your code is not there to hinder.
Cheers,
Jussi
More information about the Python-list
mailing list