[Tutor] Re: glob or filter help
Barnaby Scott
bds at waywood.co.uk
Sat Jan 22 20:08:20 CET 2005
For anyone who doesn't like lambda, how about
import os
def get_fles(exts, upd_dir):
return [i for i in os.listdir(upd_dir) if i.split('.')[-1] in exts]
> -----Original Message-----
> From: tutor-bounces+bds=waywood.co.uk at python.org
> [mailto:tutor-bounces+bds=waywood.co.uk at python.org]On
> Behalf Of Javier
> Ruere
> Sent: 22 January 2005 16:25
> To: tutor at python.org
> Subject: [Tutor] Re: glob or filter help
>
>
> Jay Loden wrote:
> > Thanks! That's exactly the kind of feedback I was looking for. If
> it's not
> > too much trouble, do you think you could explain how
> lambda works, or
> just
> > point me towards a lambda explanation/tutorial that a new
> programmer can
> > understand? It seems to give you some great power but I
> really don't
> > understand how it works.
>
> Lambda defines anonymous functions. It has some
> restrictions like that
> the function must be expressed in one line and there can be no
> assigments. The syntax can be found in [1].
> Though I personaly like this keyword, I must say that it
> can make code
> less readable so I tend to use it for only for extremely simple
> snippets. The example given in the previous mail is almost
> too big. But
> then again, one must try things out to learn so use it and
> find your own
> balance.
> Also the BDFL has said he is unhappy with lambda (and
> filter, reduce
> and map) so he may remove this keyword in the future (but not before
> Python3000)[2].
>
> Javier
>
> [1] http://www.python.org/doc/2.4/ref/lambdas.html
> [2] Look in the user list if you want to learn more about
> this topics.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list