Why all the __double_underscored_vars__?

Scott David Daniels Scott.Daniels at Acm.Org
Sat Aug 8 17:50:32 EDT 2009


kj wrote:
>>> ... 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. =C2=A0(Trust me, to most of them your reply to my post would be
>>> as clear as mud.)
> Believe me, it's not me who's bringing this stuff up: *they*
> specifically ask.  That's precisely my point: it is *they* who
> somehow feel they can't avoid finding out about this stuff; they
> must run into such __arcana__ often enough to cause them to wonder.
> If at least some rank beginners (i.e. some of my students) feel
> this way, I suggest that some of this alleged __arcana__ should be
> demoted to a more mundane everyday status, without the scare-underscores.
> E.g. maybe there should be a built-in is_main(), or some such, so
> that beginners don't have to venture into the dark underworld of
> __name__ and "__main__".

Do you know about Kirby Urner's technique of calling such symbols,
"ribs," -- the access to the "stuff" Python is built from?  One nice
thing about Python is that you can experiment with what these
"__ribs__" do without having to learn yet another language.

It seems nice to me that you can use a rule that says, "stick to
normal names and you don't have to worry about mucking with the
way Python itself works, but if you are curious, looks for those
things and fiddle with them."

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list