Zen of Python
Alex Martelli
aleaxit at yahoo.com
Sat Jan 22 08:10:36 EST 2005
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
> Dave Benjamin <dave.benjamin at gmail.com> writes:
> > Can we get a show of hands for all of those who have written or are
> > currently maintaining code that uses the leaky listcomp "feature"?
>
> It's really irrelevant whether anyone is using a feature or not. If
> the feature is documented as being available, it means that removing
> it is an incompatible change that can break existing code which
> currently conforms to the spec. If the "feature" is described as the
> bug that it is, anything that relies on it is nonconformant.
>
> I do remember seeing some cute tricks (i.e. capable of becoming
> idioms) that depend on the leakage.
Sure, ``if [mo for mo in [myre.search(line)] if mo]: use(mo)`` and the
like, used to simulate assign-and-test. No doubt maintaining backwards
compat with this kind of horrors means listcomps need to keep leaking
until Python 3.0, alas. But hopefully no farther...
Alex
More information about the Python-list
mailing list