Why all the __double_underscored_vars__?

kj no.email at please.post
Sat Aug 8 08:11:19 EDT 2009


In <mailman.4446.1249683227.8015.python-list at python.org> Chris Rebert <clp2 at rebertia.com> writes:

>The double-underscores indicate that the Python interpreter itself
>usually is the caller of the method, and as such some level of "magic"
>may be associated with it. Other languages have you do the equivalent
>of `def +():` or `def operator +()` to override an operator, the
>keyword or symbol serving a similar warning that "here be magic".

In this case, then I hope that some of these __items__ get demoted
to a more mundane level, so that the notion of "magic" doesn't get
trivialized by everyday idioms like:

if __name__ == '__main__':
    # etc

There are a few in this category...  I figure that they are cases
of "atavistic magic".

I bring this up because I find it quite difficult to explain to my
students (who are complete newcomers to programming) all the
__underscored__ stuff that even rank noobs like them have to deal
with.  (Trust me, to most of them your reply to my post would be
as clear as mud.)  This suggests to me that there's something a
bit unnatural about some of these __items__.

Anyway, thanks for your post.  I see your point.

kynn



More information about the Python-list mailing list