[FP] Rewriting name bindings as expressions

Emile van Sebille emile at fenx.com
Fri May 25 11:03:13 EDT 2001


"Michael Hudson" <mwh at python.net> wrote in message
news:m37kz5jyit.fsf at atrus.jesus.cam.ac.uk...
> "Alex Martelli" <aleaxit at yahoo.com> writes:
>
> > "Richard Davies" <richardd at pobox.com> wrote in message
> > news:5078c6cc.0105250429.6830c1eb at posting.google.com...
> > > > ans = [y+1 for x in range(10) for y in (x*x,)]
> >     ...
> > > ans = [y+1 for x in range(10) for y in x*x,]
> > >
> > > are a few characters shorter!
> >
> > If saving characters is the game, skip unneded spaces:
> >
> > ans=[y+1 for x in range(10)for y in[x*x]]
>
> ans=[y+1for x in range(10)for y in[x*x]]
>

ans=[x*x+1for x in range(10)]



--

Emile van Sebille
emile at fenx.com

---------





More information about the Python-list mailing list