[Python-Dev] Assignment to None

"Martin v. Löwis" martin at v.loewis.de
Mon Jun 9 07:19:44 CEST 2008


> 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?

It's deliberate. setattr(o, "foo bar", "baz") also works, even though
"foo bar" is not an identifier. setattr doesn't take the Python grammar
into account, but only the object's structure.

Regards,
Martin


More information about the Python-Dev mailing list