Currently I'm making a game server, I actually want to make a base project for all my server products in Python. I used to use C# but I wanted to do something different so I started on Python. Although I don't know how to do something.
In C# I used to make one static 'core' class holding all data, containing the entry point and there I boot the server. Here's a small example:
using System;
namespace SERVER
{
public static class Engine
{
public static DatabaseHelper DatabaseHelper { get; private set; }
static void Main(string[] args)
{
DatabaseHelper = new DatabaseHelper();
}
}
}
Then I just could use in every class:
Engine.DatabaseHelper.SomeMethod();
Now, I want the same concept in my Python project, but I don't know how to do it.
I got this first:
DynamicEmu.py
import Engine
engine = Engine.Engine()
Engine.py
from Network.Game.GameConnectionListener import GameConnectionListener
class Engine:
gameConnection = None
def __init__(self):
gameConnection = GameConnectionListener()
def tuple_to_addr(self, tpl):
return '{0}:{1}'.format(tpl[0], str(tpl[1]))
And then in my GameConnectionListener.py I would use:
import DynamicEmu
In order to do
DynamicEmu.engine.tuple_to_addr(TUPLE HERE)
But I get this error
Traceback (most recent call last):
File "C:/Users/Josh/PycharmProjects/DynamicEmu/DynamicEmu.py", line 1, in <module>
import Engine
File "C:\Users\Josh\PycharmProjects\DynamicEmu\Engine.py", line 3, in <module>
from Network.Game.GameConnectionListener import GameConnectionListener
File "C:\Users\Josh\PycharmProjects\DynamicEmu\Network\Game\GameConnectionListener.py", line 4, in <module>
import DynamicEmu
File "C:\Users\Josh\PycharmProjects\DynamicEmu\DynamicEmu.py", line 3, in <module>
engine = Engine.Engine()
AttributeError: module 'Engine' has no attribute 'Engine'
I suck in Python so if I'm doing something REALLY wrong I understand, I want to learn so I'd appreciate every piece of help I can get :)