On 9/25/2012 10:54 AM, Peter Otten wrote:
alex23 wrote:

On Sep 26, 12:08 am, Peter Otten <__pete...@web.de> wrote:
Jayden wrote:
In the Python Tutorial, Section 9.4, it is said that

"Data attributes override method attributes with the same name."

The tutorial is wrong here. That should be

"Instance attributes override class attributes with the same name."

Except for special methods.

I would even consider replacing the whole paragraph

I agree

"""
Data attributes override method attributes with the same name; to avoid
accidental name conflicts, which may cause hard-to-find bugs in large
programs, it is wise to use some kind of convention that minimizes the
chance of conflicts. Possible conventions include capitalizing method names,
prefixing data attribute names with a small unique string (perhaps just an
underscore), or using verbs for methods and nouns for data attributes.
"""
http://docs.python.org/dev/py3k/tutorial/classes.html

with something like

"Data attributes and method attributes share the same namespace.

and instance attributes usually override class attributes

> To avoid
name conflicts consider using verbs for methods and nouns for data
attributes"

This applies within and between. I opened

http://bugs.python.org/issue16048

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to