G
Graham
How do I make a variable available to code *inside* my class in such a way
that it is available to all defs in the class? In my example below f is not
accessible within the showVars method.
class myClass:
f = [1,2,3]
def showVars ( self ):
print f # Error here as f does not exist
def main():
x = myClass()
print x.f
x.showVars()
if __name__ == "__main__":
main()
Thanks to anyone who can offer some guidance to a Python beginner!
Graham.
that it is available to all defs in the class? In my example below f is not
accessible within the showVars method.
class myClass:
f = [1,2,3]
def showVars ( self ):
print f # Error here as f does not exist
def main():
x = myClass()
print x.f
x.showVars()
if __name__ == "__main__":
main()
Thanks to anyone who can offer some guidance to a Python beginner!
Graham.