squared functions--most Pythonic way?

Giorgi Lekishvili gleki at gol.ge
Fri Jun 28 10:38:18 CEST 2002


One of the biggest advantages of Python is its nice and elegand mixture of
procedural, OO and functional programming... I would prefer lambda stile as the
most concise, but it is a matter of personal "phylosophy";)

Grtz,
Giorgi

Sean 'Shaleh' Perry wrote:

> >
> > functional programming:
> >
> >     # with an internal named function
> >     def fsquare(f):
> >         def f2(x):
> >             return f(x)**2
> >         return f2
> >
>
> this seems to be the most pythonic (lambda is not the preferred approach
> usually).
>
> Of course someone will mention taking this to the next step with a compose()
> function which take f(x) and g(x).




More information about the Python-list mailing list