Re: Python class and variable issue(newby question!)

2013-03-29 Thread Dave Angel
On 03/29/2013 06:17 PM, Sam Berry wrote: Thanks for the responses! My issue was sorted with Benjamins post, just printing s worked. Cheers for the info though Chris, if i have any further issues il post them with some working code. In that case, you probably should add a line like: s = Non

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 9:51 AM, Steven D'Aprano wrote: > On Sat, 30 Mar 2013 08:24:00 +1100, Chris Angelico wrote: > >> On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry >> wrote: >>> class test() >>> s = 1 >>> >>> def test1() >>> global s >>> s = 2 > >> That's not a global, tha

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Steven D'Aprano
On Sat, 30 Mar 2013 08:24:00 +1100, Chris Angelico wrote: > On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry > wrote: >> class test() >> s = 1 >> >> def test1() >> global s >> s = 2 > That's not a global, that's a class variable. /me thwacks Chris with a halibut. Not only i

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 9:17 AM, Sam Berry wrote: > Thanks for the responses! My issue was sorted with Benjamins post, just > printing s worked. > > Cheers for the info though Chris, if i have any further issues il post them > with some working code. Awesome! Always happy to help out. ChrisA -

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Sam Berry
Thanks for the responses! My issue was sorted with Benjamins post, just printing s worked. Cheers for the info though Chris, if i have any further issues il post them with some working code. Sam -- http://mail.python.org/mailman/listinfo/python-list

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Benjamin Kaplan
On Fri, Mar 29, 2013 at 2:12 PM, Sam Berry wrote: > Hey, > > Im new to object orientated programming and have an issue with using classes. > Im using the kivy module, a GUI creator , so posting the actual code may > confuse. But an example of what im trying to achieve is below > > class test() >

Re: Python class and variable issue(newby question!)

2013-03-29 Thread Chris Angelico
On Sat, Mar 30, 2013 at 8:12 AM, Sam Berry 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 gi

Python class and variable issue(newby question!)

2013-03-29 Thread Sam Berry
Hey, Im new to object orientated programming and have an issue with using classes. Im using the kivy module, a GUI creator , so posting the actual code may confuse. But an example of what im trying to achieve is below class test() s = 1 def test1() global s s = 2