I am trying to develop a robot for Skype and I am having difficulties with certain classes and how to use only one instance instead of creating a new one within another file.
I have many files in which the robot runs from and I want to only use one instance via a Global.py
file:
from classes import class_Core
from classes import class_Skype
from classes import class_Message
from classes import class_Commands
global Core, Skype, Message, Commands
Core = class_Core.Core()
Skype = class_Skype.Skype()
Message = class_Message.Message()
Commands = class_Commands.Commands()
I also have a Skypebot.py
file which imports the Global.py
file:
import Global
However, when I run Skypebot.py
and use a function from Core in the Skype class:
class Skype:
def __init__(self):
Core.Log("Initialising Skype!")
I get an trace back:
Traceback (most recent call last):
File "C:\Users\Connor\Desktop\Skypebot 0.4\Skypebot.py", line 1, in <module>
import Global
File "C:\Users\Connor\Desktop\Skypebot 0.4\Global.py", line 9, in <module>
Skype = class_Skype.Skype()
File "C:\Users\Connor\Desktop\Skypebot 0.4\classes\class_Skype.py", line 8, in
__init__
Core.Log("Initialising Skype!")
NameError: global name 'Core' is not defined
Can anybody help me on this? Thanks!