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 http://www.python.org/dev/peps/pep-0008/

HTH,

Emile



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to