Hi Dave,

You are causing yourself some confusion by still treating variables
as something other than a name. Your first paragraph says:

(Actually, functions and classes are just variables that hold
references to function and class objects.)

Which is wrong. variables are simply names that refer to objects,
which includes functions and classes(and instances of classes)
Thus a function is never a variable. variables refer to functions.

In Computer Science terms a function is a lamda expression
and a def in Python should be a shorthand way of doing

var = lambda params... : expression

Unfortunately, in practice, in Python it's the other way around.
The lambda is really an alternative for

def var(params...):
    return expression

But it is important to realize that names in Python - all names - are
simply references to objects of some kind. and that classes, 
instances,
functions, numbers, lists, characters etc  are all objects in this 
sense.

-------------
On the term Global you should probably specifically note that
in Python global really means module scope. In some languages
global implies visible across all modules(like Python built-ins),
in Python it just means visible within the current file(aka module)
--------------
Typo (I assume):
"For example, in the following function, the variable count is not 
bound
to a value until the end of the second iteration of the loop"

I assume you meant to say x not count?
count is bound at the end of *every* iteration.
--------------
On the binding section when addressing formal parameters its worth
pointing out that the binding occurs at function *invocation* not at
definition. Also the parameters get rebound on each invocation.
Finally, default arguments are only bound once.
---------------
On dir() and vars() - its worth pointing out that both functions take
an optional argument and are not restricted to showing the current
local symbol table values.
----------------

A good first attempt, hopefully the above comments can tighten it
up a wee bit more.

Thanks for sharing, these kind of web notes are always handy for
folks searching for additional help - in addition to yourself of 
course!

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



"Dave Kuhlman" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've written up a few notes on Python namespaces and scopes.  If
> anyone has corrections, comments, or suggestions, I'd appreciate
> them. You can find my comments here:
>
>    http://www.rexx.com/~dkuhlman/python_comments.html#namespaces
>
> I wrote these notes because I found that I did not understand
> Python namespaces as well as I thought I did.  Writing the
> comments seemed like a good way to work through and learn about
> namespaces, scopes, variables, bindings, etc.
>
> By the way, I was motivated to write these notes because of the
> "loops to assign variables" thread on this list a few days ago.
> I'm hoping that my notes show that I learned from that thread.
>
> Dave
>
> -- 
> Dave Kuhlman
> http://www.rexx.com/~dkuhlman
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to