namespaces & indentation

Chris Schaller Chris.Schaller at web.de
Sat Dec 23 07:36:15 EST 2000


[Tim Peters]
>Very close.  Scopes are defined with respect to "execution frames", which
>are in turn attached to "code blocks", and the code block of a function is
>its entire body (less the bodies of nested functions and classes).  The
>complete rules are here:
>
>    http://www.python.org/doc/current/ref/execframes.html
>
>Well worth reading!  The answers to many "deep" questions are waiting there.
I've already taken a look in my despair at that document, but couldn't believe
that the smallest piece of code with its own namespace is a function.

  This implies (at least to me) to keep functions as small as possible in
order to avoid further complications (at least some functional programming
philosophy...).  But that would mean slow down, since function calling causes
much more overhead (or has this changed in Python 2.0?).

  I know this indenting/scoping stuff from Haskell, so I assumed, Python
didn't only adopt omitting ;s, {s, }s, and similar rubbish, but that was
only my assumption (next time I'll take a closer look at the documentation)...

>1. Strive to test all paths thru each function (good advice regardless of
>language).
That's right, but that's not so easy in Python (sorry, I'm a little bit
fastidious from using FPLs) due to its dynamics.  Otherwise such cases
would have been analyzed and criticized when parsing the function.  The same
applies to a function that gets a wrong argument type and runs amuck.

bye
  Chris...



More information about the Python-list mailing list