Fwd: Re: [Tutor] instance variables and the instance dictionary

Magnus Lycka magnus@thinkware.se
Fri Jan 10 20:17:02 2003


At 17:40 2003-01-10 -0700, Bob Gailer wrote:
>Yep; that's it! How easy to overlook the obvious.

It's always nice when we see that the pieces fall
back into the places where we expect them to be, right?
I was also a bit surprised before I understood the
obvious...

There are those who complain loudly over the explicit
self in Python. In a way it feels a little low level,
that you are aware of the implementation and can peek
behind the curtains. But I feel that it's reassuring
that things are very consistent. And the ability to
peek behind the curtains is one of Pythons best features.
There is a little shortcut for instance objects that
call the methods defined in its class.

Instead of calling

x.__class__.clear(x)

we can simply call

x.clear()

Otherwise there is basically no magic with classes.
(Well, apart from the __magic__ methods.) Classes are
just holders of the method code that will be available
to instances created through their __init__ methods.


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se