On Mon, 9 Jun 2008 12:24:55 pm Curt Hagenlocher wrote: > So, it's okay to setattr the attribute name "None" but not okay to > set it directly?
I suspect this is off-topic for python-dev, and would be better on comp.lang.python or similar, but for what it's worth, I consider having an attribute named 'None' bad practise, regardless of any runtime checks. But as part of Python's "we're all consenting adults here" philosophy, I wouldn't approve of expensive or extensive run-time checks specifically to prevent it. If you really have to name your attribute None, and are prepared to live with the consequences, then go ahead. In a similar fashion: >>> class Parrot(object): ... pass ... >>> p = Parrot() >>> p.1 = 'spam' File "<stdin>", line 1 p.1 ^ SyntaxError: invalid syntax >>> setattr(p, '1', 'spam') >>> -- Steven _______________________________________________ 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