Is it seen as bad practice to try to hide local functions in Python? The intention not to clutter the global namespace with second rank or common function names may stand against ... er... some Pythonisms that I am not aware of.
def foo(aparameter):
def somenamewhichislikelytoclash(anotherparam):
....
Is there a runtime penalty? AFAIK all functions contexts are created on the heap anyway, so binding and destroying would take just as much time for locals - is there more?
I am asking this for the Python context specifically, as I know enough about separation of concerns, clean keeping of namespace etc. in other languages.
somenamewhichislikelytoclash
function is only used withinfoo
, and is indeed likely to clash its name with some other function within the same module, a closure makes perfect sense.from module import *
), but this is a bad practice in itself, so let's ignore that.stepix
etc. where no two stepping functions tend to be identical.