[New-bugs-announce] [issue16048] Tutorial-classes-remarks: replace paragragh

Terry J. Reedy report at bugs.python.org
Tue Sep 25 22:06:02 CEST 2012


New submission from Terry J. Reedy:

(from python-list thread "data attributes override method attributes?")

"9.4. Random Remarks

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."

The first semi-sentence is wrong. Within a class or instance attribute space, later assignments replace earlier ones. Between them, instance attributes (usually) override class attributes. The exceptions are (some? all?) special methods. One suggestion on the thread is to replace the clause with 'Instance attributes override class attributes', as that is the apparent intent, but the exception needs to be noted.

The suggested Method and _data conventions are wrong in that they contradict PEP8 style. Peter Otten suggested that the convention suggestion be shortened to "To avoid name conflicts consider using verbs for methods and nouns for data attributes".

----------
assignee: docs at python
components: Documentation
messages: 171316
nosy: docs at python, terry.reedy
priority: normal
severity: normal
status: open
title: Tutorial-classes-remarks: replace paragragh
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16048>
_______________________________________


More information about the New-bugs-announce mailing list