[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:53:46 -0500 (EST)


>>>>> "GvR" == Guido van Rossum <guido@digicool.com> writes:

  >> 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('_')]

  GvR> But that shouldn't be used in /F's modules, because he wants
  GvR> them to be 1.5 compatible.  Anyway, filter(lambda s: s[0]!='_',
  GvR> dir()) is shorter, and you prove that it isn't faster. :-)

Well, if he wants it to work with 1.5.2, that's one thing.  But the
list comprehensions is clear are short done your way:

__all__ = [s for s in dir() if s[0] != '_']

Jeremy