__getattr__, __setattr__

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Heller

    #1

    __getattr__, __setattr__

    Just wondering about this behaviour, why is it this way?

    Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
    Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
    >>> object.__setatt r__[/color][/color][/color]
    <slot wrapper '__setattr__' of 'object' objects>[color=blue][color=green][color=darkred]
    >>> object.__getatt r__[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    AttributeError: type object 'object' has no attribute '__getattr__'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]


    Thanks,

    Thomas
  • wittempj@hotmail.com

    #2
    Re: __getattr__, __setattr__

    for new style classes __getattribute_ _ is defined, see eg.


    Comment

    • Steve Holden

      #3
      Re: __getattr__, __setattr__

      Thomas Heller wrote:[color=blue]
      > Just wondering about this behaviour, why is it this way?
      >
      > Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
      > Type "help", "copyright" , "credits" or "license" for more information.
      >[color=green][color=darkred]
      >>>>object.__se tattr__[/color][/color]
      >
      > <slot wrapper '__setattr__' of 'object' objects>
      >[color=green][color=darkred]
      >>>>object.__ge tattr__[/color][/color]
      >
      > Traceback (most recent call last):
      > File "<stdin>", line 1, in ?
      > AttributeError: type object 'object' has no attribute '__getattr__'
      >[/color]
      Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
      win32
      Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
      >>> object.__getatt ribute__[/color][/color][/color]
      <slot wrapper '__getattribute __' of 'object' objects>

      Ring any bells?

      regards
      Steve
      --
      Steve Holden +44 150 684 7255 +1 800 494 3119
      Holden Web LLC www.holdenweb.com
      PyCon TX 2006 www.python.org/pycon/

      Comment

      • Thomas Heller

        #4
        Re: __getattr__, __setattr__

        "wittempj@hotma il.com" <martin.witte@g mail.com> writes:
        [color=blue]
        > for new style classes __getattribute_ _ is defined, see eg.
        > http://www.python.org/2.2.3/descrintro.html[/color]

        Steve Holden <steve@holdenwe b.com> writes:
        [color=blue][color=green][color=darkred]
        > >>> object.__getatt ribute__[/color][/color]
        > <slot wrapper '__getattribute __' of 'object' objects>
        >
        > Ring any bells?[/color]

        Yes, of course. Thanks ;-)

        Thomas

        Comment

        Working...