howto overload with a NOP (empty statement)
tiedon_jano at hotmail.com
Sat Jan 6 15:34:35 CET 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".
> 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...
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):
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.
More information about the Python-list