[Tutor] properties beginner M Dawson book

Emile van Sebille emile at fenx.com
Mon Jun 11 15:36:59 CEST 2012

On 6/10/2012 4:58 AM Steven D'Aprano said...
> Nicholas Harman wrote:
>> I have done a little programming in BlueJ Java before but I decided to
>> try
>> the “Python style” as explained in the chapter, using properties rather
>> than variables and getters and setters ..... My main question is: When
>> using property and setter it seems I must use “__name” or “__volume”
>> (Python’s version of private variables). Is this true?
> Certainly not. Python doesn't enforce any naming convention on you. You
> can use any name you like. But you *should* use something like "__name"
> or "__volume", simply because that will be more sensible than most other
> names. But if you choose to use something else, Python won't stop you.

Note that use the doubleunderscore names is a special construct that 
invokes name mangling.  You might want to introduce them when teaching 
about sub-classing.  Pep 8 speaks to their use.  See 



More information about the Tutor mailing list