[Python-ideas] relaxing keyword usage restrictions

Terry Reedy tjreedy at udel.edu
Wed Sep 7 23:26:49 CEST 2011


On 9/6/2011 10:47 PM, Nick Coghlan wrote:
> On Wed, Sep 7, 2011 at 11:57 AM, Barry Warsaw<barry at python.org>  wrote:
>> On Sep 07, 2011, at 10:21 AM, Nick Coghlan wrote:
>>
>>>>> class Foo:
>> ...    """I'm still -1 myself, but such a delimited approach at least has the
>> ...    virtue of addressing the *entire* scope of the identifier syntax
>> ...    limitation rather than singling out keywords for special treatment.
>> ...
>> ...    Legitimate use cases for such a feature would include at least those
>> ...    currently handled by the 'rename' flag on the namedtuple constructor
>> ...    (the latter would still be needed to handle duplicate field names,
>> ...    but illegal identifiers could just be quoted).
>> ...    """ = False
>>
>> frightening-ly y'rs,
>
> Even worse:
>
> class Foo:
>      '' = True
>
> Utterly untenable :)

And completely possible with set/getattr ;=)

I personally think the current de facto rule is fine: any identifier can 
be and must be acceptable as an attribute name; the use of anything else 
by indirect non-attribute-reference means (set/getattr, .__dict__, or 
otherwise) is implementation dependent.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list