[FRPythoneers] Leading _ in name?

jafo at tummy.com jafo at tummy.com
Tue May 22 03:17:57 MDT 2001


My impression from the discussion tonight was that something had been done
to treat a name in a module that has a leading underscore specially to
"hide" it.  Doesn't seem to be the case in Python 2.1 though.  What's the
story?

f.py:
   a = 1
   _b = 2
   def foo(): return(1)
   def _bar(): return(1)

then:
   >>> import f
   >>> print f
   <module 'f' from 'f.py'>
   >>> print dir(f)
   ['__builtins__', '__doc__', '__file__', '__name__', '_b', '_bar', 'a',
   'foo', 'rcsid', 'revision']
   >>> print f._b
   2
   >>> print f.a
   1
   >>> f._bar()
   1
   >>> f.foo()
   1
   >>> from f import _bar

Seems like _bar is there...

Sean
-- 
 It is far from clear whether "good intentions plus stupidity" or "evil
 intentions plus intelligence" have wrought more harm in the world.
                 --- Domer, The Logic of Failure
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python



More information about the FRPythoneers mailing list