On Sun, Jun 8, 2008 at 9:24 PM, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > My apologies if this is one of those "dead horse" issues. The > following seems a little inconsistent to me: > >>>> c = C() >>>> c.None > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: C instance has no attribute 'None' >>>> c.None = 'foo' > File "<stdin>", line 1 > SyntaxError: assignment to None >>>> setattr(c, 'None', 'foo') >>>> c.None > 'foo' >>>> > > So, it's okay to setattr the attribute name "None" but not okay to set > it directly? Is this deliberate or is it an unintentional side effect > of parser changes to prevent assignment to None?
I believe that runtime checks like the one needed for setattr would be too much of a performance hit to be practical. The syntax changes are meant to avoid mistakes and confusion rather than completely prevent something from ever happening. -- Cheers, Benjamin Peterson "There's no place like 127.0.0.1." _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com