[Python-Dev] pydoc for named tuples is missing methods

Michael Foord fuzzyman at voidspace.org.uk
Tue Mar 15 15:22:44 CET 2011


On 15/03/2011 07:59, Nick Coghlan wrote:
> On Tue, Mar 15, 2011 at 6:20 PM, Eric Smith<eric at trueblade.com>  wrote:
>> The field names are not always under direct control of the developer, such
>> as when they are database column names. Not that using _replace completely
>> gets rid of this problem, but I agree with Raymond's decision that a field
>> name can be any valid identifier not starting with an underscore. It's the
>> simplest thing for the developer using namedtuple.
> While I actually think the current API design is a decent compromise,
> another option to consider would be to move the underscore to the
> *end* (as_dict_, replace_, make_) as is sometimes done for code that
> needs to avoid conflicting with a keyword.
>
> Namespace collisions with actual fields would remain unlikely, while
> pydoc would pick up the new names correctly.
>

Although it's a backwards incompatible change. Teaching pydoc to 
recognise the private methods isn't.

Michael

> Cheers,
> Nick.
>


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html



More information about the Python-Dev mailing list