Python class and variable issue(newby question!)
Chris Angelico
rosuav at gmail.com
Fri Mar 29 17:24:00 EDT 2013
On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry <sambez_14 at hotmail.co.uk> wrote:
> class test()
> s = 1
>
> def test1()
> global s
> s = 2
>
> def test2()
> global s
> s = 3
>
> def test3()
> global s
> s = 4
That's not a global, that's a class variable. But to give any more
specific help, it'd be helpful to have some actual working code -
twiddle your code until it's a nice simple example:
http://sscce.org/
Most likely, what you want is to make these functions into either
static methods or instance methods. Beyond that, hard to say exactly.
ChrisA
More information about the Python-list
mailing list