1

Please excuse my English

I have multiple modules within many classes and I want to create an initial file to contain a few numbers of object created from classes. I did this by importing it in another file to use the object that I created. Is there any way for me to run the code in initial.py once but import it multiple times for many files? I don't want to run the __init__ function inside the classes that I have multiple times. I found out that I can do it in a very simple way with if function like this:

import role, strategy

i = 1
if (i == 1):
   player = role.Attacker()
   player_strategy = strategy.Attacker()
   i += 1

Is there any smarter way to do it?

Jared Forth
  • 1,577
  • 6
  • 17
  • 32
Quan
  • 41
  • 4

0 Answers0