Roger Lovelock wrote:
> At the risk of revealing my ignorance!
> 
> I see a lot of underscores and double underscores used in python/dabo 
> variable names and also when looking at some menu code a construction with 
> brackets an underscore and then further brackets eg
> 
> vm.append(_("Display Methods", ... etc   ))
> 
> and, of course,      __main__ etc etc
> 
> I have always had a vague idea that the underscores indicate a local 
> variable ie confined to the current context level. Is that how it is used in 
> python/dabo, or does the underscore have a more significant meaning?
> 
> Sorry if this is a bit basic.

You can find the meaning in the "Python Style Guide" (PEP 8) in the
section "Naming Conventions":
http://www.python.org/dev/peps/pep-0008/

"""
In addition, the following special forms using leading or trailing
underscores are recognized (these can generally be combined with any
case convention):
    - _single_leading_underscore: weak "internal use" indicator.  E.g.
      "from M import *" does not import objects whose name starts with
      an underscore.

    - single_trailing_underscore_: used by convention to avoid conflicts
      with Python keyword, e.g.
      Tkinter.Toplevel(master, class_='ClassName')

    - __double_leading_underscore: when naming a class attribute,
      invokes name mangling (inside class FooBar, __boo becomes
      _FooBar__boo; see below).

    - __double_leading_and_trailing_underscore__: "magic" objects or
      attributes that live in user-controlled namespaces.  E.g.
      __init__, __import__ or __file__.  Never invent such names; only
      use them as documented.
"""

Uwe


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to