Python syntax in Lisp and Scheme

Terry Reedy tjreedy at udel.edu
Sun Oct 12 00:30:44 EDT 2003


"Pascal Costanza" <costanza at web.de> wrote in message
news:bm9it8$6j5$1 at newsreader2.netcologne.de...
> Does Python allow local function definitions?

Module level functions are local to the module unless imported by
another module.  Nested functions are local to the function they are
nested within unless explicitly returned.  Methods are local to
classes and subclasses.  Lambda expressions are very local unless
somehow passed around.

I am not sure which best meets your intention.

>Can they shadow predefined functions?

Yes, named objects, including functions can (locally) shadow
(override) builtins.  It is considered a bad habit/practice unless
done intentionally with a functional reason.

Terry J. Reedy






More information about the Python-list mailing list