my favorite line of py code so far

Chris Angelico rosuav at gmail.com
Sat Nov 9 07:45:45 EST 2013


On Sat, Nov 9, 2013 at 11:41 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> 2) "this is a non-public thing", as in
>
>     class Xyz:
>         _private = 1

Your three meanings all have the etymology of "ignore me", but I would
distinguish this one from the others. An underscore used on its own
has meaning; an underscore as part of a larger token has quite
different meaning, and can have any of several - "private-ish" (as
above), "mangle me" (double leading, no trailing), "magic" (dunder -
double leading/double trailing), and "word separator"
(between_multiple_words_in_an_identifier). Your other two examples are
what we're talking about here, though.

ChrisA



More information about the Python-list mailing list