Beginner's scoping question
James Stroud
jstroud at mbi.ucla.edu
Wed Nov 10 15:51:14 EST 2004
If you make an assignment in a method, the name assumes a local scope in
python. "b" was not assigned so did not assume local scope.
James
On Wednesday 10 November 2004 12:40 pm, Alan Little wrote:
> a=1
> b=[]
> class C():
> def __init__(self):
> a=2
> b.append(3)
>
> c = C()
>
> print b
> # [3]
>
> # but ...
> print a
> # 1
>
> ???
--
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
611 Charles E. Young Dr. S.
MBI 205, UCLA 951570
Los Angeles CA 90095-1570
http://www.jamesstroud.com/
More information about the Python-list
mailing list