[Tutor] Understanding Object oriented programming with Python

Alan Gauld alan.gauld at yahoo.co.uk
Sat Sep 5 04:31:30 EDT 2020


On 05/09/2020 05:06, Manprit Singh wrote:

> secondarily if i have to define a class,with a class name like
> "twostageamplifier". The definition could be written as given below:
> Class name is made up of 3 words "two", "stage", "amplifier".
> 
> class TwoStageAmplifier:          # Using CapWords convention.

That's the style I use but this is where it gets more controversial,
with some folks preferring underscores. So:

TwoStageAmplifier
Two_stage_amplifier
Two_Stage_Amplifier

would all be acceptable.
The idea of the initial capital letter is just to signal to
readers that it is a type(class) rather than a function
(all lower case). In a similar way that constants are
usually signalled by being all UPPERCASE


You will also find that classes defined in the standard
library are (nearly?) all lowercase_with_underscores.
(Which is a bad thing IMHO!)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list