[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Lib sre_constants.py (etc)

Jeremy Hylton jeremy@alum.mit.edu
Thu, 15 Feb 2001 18:34:31 -0500 (EST)


>>>>> "SM" == Skip Montanaro <skip@mojam.com> writes:

  Fredrik> can anyone explain why it's a good idea to have totally
  Fredrik> incomprehensible stuff like

  Fredrik> __all__ = locals().keys() for _i in
  Fredrik> range(len(__all__)-1,-1,-1): if __all__[_i][0] == "_": del
  Fredrik> __all__[_i] del _i

  Fredrik> in my code?

  SM> Please don't shoot the messenger... ;-)

  SM> In modules that looked to me to contain nothing by constants, I
  SM> used the above technique to simply load all the modules symbols
  SM> into __all__, then delete any that began with an underscore.  If
  SM> there is no reason to have an __all__ list for such modules,
  SM> feel free to remove the code, just remember to also delete the
  SM> check_all() call in Lib/test/test___all__.py.

If __all__ is needed (still not sure what it's for :-), wouldn't the
following one-liner be clearer:

__all__ = [name for name in locals.keys() if not name.startswith('_')]

Jeremy