This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients docs@python, terry.reedy
Date 2012-09-25.20:05:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348603562.92.0.789475109772.issue16048@psf.upfronthosting.co.za>
In-reply-to
Content
(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".
History
Date User Action Args
2012-09-25 20:06:02terry.reedysetrecipients: + terry.reedy, docs@python
2012-09-25 20:06:02terry.reedysetmessageid: <1348603562.92.0.789475109772.issue16048@psf.upfronthosting.co.za>
2012-09-25 20:05:41terry.reedylinkissue16048 messages
2012-09-25 20:05:41terry.reedycreate