setattr using invalid attribute names - bug or feature?

From: Gerson Kurz (gerson.kurz_at_t-online.de)
Date: 06/14/04


Date: Mon, 14 Jun 2004 14:22:17 GMT

I stumbled across this (while using my homebrewn enum class):

    class test:
        pass

    instance = test()
    setattr(instance, "THIS :*2+~# IS OBVIOUSLY INVALID", 123)

I would've expected some kind of error message here when calling
setattr(); after all, its not a regular attribute? Plus, documentation
says

"
 Set a named attribute on an object; setattr(x, 'y', v) is equivalent
to
    ``x.y = v''.
"

and you cannot write this:

instance.THIS :*2+~# IS OBVIOUSLY INVALID = 123

(oh, and its: PythonWin 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200
32 bit (Intel)] on win32.)



Relevant Pages

  • Re: setattr using invalid attribute names - bug or feature?
    ... > I would've expected some kind of error message here when calling ... > setattr(); after all, ...
    (comp.lang.python)
  • Problem calling Fill() method
    ... daAddress dataset, the update works fine and even enters a new row inside ... conflict occurred in database 'OFS', table 'Address', column 'address_id'. ... discovered this error message: ... Now, the zip column is indeed populated upon calling the Updatemethod, ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Problem calling Fill() method
    ... daAddress dataset, the update works fine and even enters a new row inside ... conflict occurred in database 'OFS', table 'Address', column 'address_id'. ... discovered this error message: ... Now, the zip column is indeed populated upon calling the Updatemethod, ...
    (microsoft.public.sqlserver.programming)
  • Problem calling Fill() method
    ... daAddress dataset, the update works fine and even enters a new row inside ... conflict occurred in database 'OFS', table 'Address', column 'address_id'. ... discovered this error message: ... Now, the zip column is indeed populated upon calling the Updatemethod, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Problem calling Fill() method
    ... daAddress dataset, the update works fine and even enters a new row inside ... conflict occurred in database 'OFS', table 'Address', column 'address_id'. ... discovered this error message: ... Now, the zip column is indeed populated upon calling the Updatemethod, ...
    (microsoft.public.dotnet.framework.adonet)