When I run my program core.py (http://pastebin.com/kbzbBUYd) it returns:
File “core.py”, line 47, in texto
core.mail(numbersendlist, messagetext)
NameError: global name ‘core’ is not defined
Can anyone tell me what is going on and how I can stop this error?
If it helps, the “import carrier” line in core.py refers to carrier.py (http://pastebin.com/zP2RHbnr)
You’re getting
NameErrorBecause there’s no such namecoredefined in your code in either local or global scope. Create aCoreobject first before calling it’s methods.Also the indentation of
texto()is probably wrong. You won’t be able to use this function from rest of the module. If you want to use it from other parts of current module or from other modules, declare the function at module level or use the@staticmethoddecorator to if you want to make it a static method of the class.This should work.