Py3K idea: why not drop the colon?
Stephen Eilert
spedrosa at gmail.com
Tue Nov 14 15:59:24 EST 2006
Carl Banks escreveu:
> 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
Well, I *hate* underscores with a passion. So it is kinda frustrating
that I *have* to say "__init__". The fact that the coding conventions
for Python suggest things such as methods_called_this_or_that do not
help. Everything else seems fine, since if there's voodoo involved, it
had best be sticking out from the text in big, bloody, blinking, red
letters.
I know, there's noone preventing me from doing otherwise (except for
that blasted __init__). I'd like to follow the pack here, tho.
Stephen
More information about the Python-list
mailing list