On 7/17/2017 10:27 PM, Rick Johnson wrote:
On Monday, July 17, 2017 at 12:20:04 PM UTC-5, Steve D'Aprano wrote:collections.namedtuple generates a new class using exec, and records the source code for the class as a _source attribute. Although it has a leading underscore, it is actually a public attribute. The leading underscore distinguishes it from a named field potentially called "source", e.g. namedtuple("klass", ['source', 'destination']).Although i understand the reasoning behind using the leading underscore, the Python devs should have realized that anyone who follows Pythonic convention [1] will ignore a symbol that starts with an underscore . So if the intention is that `_source` should be a part of the public API, then obviously, defining it in "standardized private form" is very unwise. But to answer your question, no, none of my code relies on the `_source` attribute. So i really don't care what happens to it. [1] Which i would hope is a rather large group, and not just another "Rick singleton".
Yes, No. The developers of the class agree that a trailing underscore convention would have been better. 'source_' etc.
-- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
