Py3K idea: why not drop the colon?
Carl Banks
pavlovevidence at gmail.com
Mon Nov 13 20:00:41 EST 2006
Steve Holden wrote:
> In fact most Python doesn't use such constructs, though I'll admit the
> occasional __init__ is more or less inevitable once you start using the
> object-oriented features more than casually.
Occasional? I don't know about you, but I use __init__ in 99% of the
classes I define. :) I don't think __special_symbols__ are manifestly
unsuitable for newbies--they're just special.
I was curious how much I used these symbols. For my current largish
project:
306 __init__
68 __future__
44 __dict__
3 __name__
3 __main__
3 __import__
3 __builtin__
2 __str__
2 __file__
1 __setitem__
1 __setattr__
1 __repr__
1 __or__
1 __ne__
1 __int__
1 __getitem__
1 __getattribute__
1 __eq__
1 __call__
1 __add__
Excepting my use of __dict__, not a whole lot advanced usage there, and
I am NOT the kind of person who's afraid to do advanced things when
it's useful. Much of the advanced stuff, including __dict__, is for
debugging. (I have a lot of classes that acquire resources that I must
explicity release, so I clear the __dict__ to catch any post-release
accesses, which could cause subtle failures otherwise.)
Carl Banks
More information about the Python-list
mailing list