nested functions

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Jun 14 20:35:20 EDT 2006


"Gregory Petrosyan" <gregory.petrosyan at gmail.com> writes:

> I often make helper functions nested, like this:
> 
> def f():
>     def helper():
>         ...
>     ...
> 
> is it a good practice or not?

You have my blessing. Used well, it makes for more readable code.

> What about performance of such constructs?

What about it? Set up some examples maningful for your situation, with
and without such constructs, and use the profiler to find out.

-- 
 \      "People demand freedom of speech to make up for the freedom of |
  `\            thought which they avoid."  -- Soren Aabye Kierkegaard |
_o__)                                                      (1813-1855) |
Ben Finney




More information about the Python-list mailing list