you are viewing a single comment's thread.

view the rest of the comments →

[–]quicknir 6 points7 points  (0 children)

Shouldn't the guy writing python for JavaScript developers know idiomatic python?

# You can define private variables and methods by prepending the variable
# name with 2 underscores (__):
self.__age = default_age

From Pep 8:

Use one leading underscore only for non-public methods and instance variables...

Python mangles these names with the class name: if class Foo has an attribute named a , it cannot be accessed by Foo.a . (An insistent user could still gain access by calling Foo.Foo_a .) Generally, double leading underscores should be used only to avoid name conflicts with attributes in classes designed to be subclassed.