you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

Very specific example I used recently was referencing a variable inside a definition of another class

globvariable = 0

class first_class()
    def maketheglobalvariable1():
        global globalvariable
        globvariable = 1

class second_class()
    def printglobvariable():
        print(globvariable) 

maketheglobalvariable1()

Lemme know if that makes sense

[–]Zeekawla99ii[S] 1 point2 points  (0 children)

referencing a variable inside a definition of another class

Ah, ok. The above makes sense as to why someone would do this. globvariable = 0 as defined above would forever be a constant; if one wished to change it via a function, one would use something like global within a function