learning-python question

gbp gpepice1 at nycap.rr.com
Fri Jul 28 23:02:36 EDT 2000


I'm new to python but it looks like your varible is out of scope.  Try
declaring it as a global (just put the work global in front of it) or
try moving it so its inside the function.  It you declare a varible at
top level its isn't automatically global.  Its local to the top level.

JeremyLynch at fsmail.net wrote:
> 
> hi,
> I have just started learning python, although I am already confident in
> c/c++, and I finding some of python's features confusing. This may seem
> like a *very* stupid question so ignore it if you want to :)
> My problem simplifies to:
> 
> count = 5
> 
> def count_func()
>      print count
>      count = count + 1
> 
> count_func()
> 
> Why can count_func() not see count (it throws up a 'name'
> or 'attribute' error)
> 
> thanks if you can help,
> 
> ----------------------
> jeremylynch at fsmail.net
> ----------------------
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.



More information about the Python-list mailing list