I have a python class,called settings, which includes an __init__
method for setting some values as below:
class settings:
global appkey
global appversion
def __init__(self):
appkey = 1
appversion = 1
applicationname = "app1"
applicationfile = "app.txt"
In another python file(main script), I define an instance of my settings class via this codes:
import settings
from settings import settings
set = settings()
print set.appversion
print set.appkey
print set.applicationfile
But when I run my main python script, I got this error:
AttributeError: settings instance has no attribute 'appversion'
I expect that when I am defining an instance of a class, settings class here, its init function will be triggered and I will have values for its attributes.