[Tutor] Why thus?

Arthur Siegel ajs@ix.netcom.com
Sun, 12 Mar 2000 15:56:19 -0500


> :: Use the "global" statement, i.e. "global counter" within
> :: __init__.
>
>
> Additionally, Arthur, you would probably benefit from reading
> (rereading?) the Python Tutorial, Chapter 9, Section 2 -- "Python Scopes
> and Name Spaces," so as to have an overview of why global is necessary
> here.

The global statement clearly solves the practical problem.  But having now
reread the
scope and name space section, I can't say I fully get it.

My problem seems to be understanding the significant difference between the
    "print counter" statement - which can print  the value of the "counter"
variable from within the class __init__
                and the
    "counter=counter+1"
                which generates the error saying I never heard of "counter".
    Then why can it print the value.

See where my confusion lies?