Jan-25-2020, 06:22 AM
Hello,
File Structure:
DND:
Simple_Melee.py:
I like the structure that I am currently using, but I am relatively new to these more advanced file structurings. If there is a better way, feel free to explain that instead of this, because I know that import * is a bad idea.
Thank you,
- DD169
File Structure:
DND:
- testing.py
- Weapons:
- __init__.py
- Simple_Melee.py
- Simple_Ranged.py
- Martial_Melee.py
- Martial_Ranged.py
- __init__.py
Simple_Melee.py:
quarterstaff = { 'damage': '1d6', 'versatile_damage': '1d8' }testing.py:
from Weapons import * # print(quarterstaff) # Doesn't work print(Simple_Melee.quarterstaff) # Does work, but not what I want from Weapons.Simple_Melee import * from Weapons.Simple_Ranged import * from Weapons.Martial_Melee import * from Weapons.Martial_Ranged import * print(quarterstaff) # Works as I want, but I have to have 4 import statements to get all weapons loadedHow do I import all dictionaries (weapons) into testing.py? Or more concisely, is there a better way than four import statements? If not, then the next best thing will be to move all of the weapons into the same file, but I like having things better organized than that. I need to access these dictionaries by name, not by module.name.
I like the structure that I am currently using, but I am relatively new to these more advanced file structurings. If there is a better way, feel free to explain that instead of this, because I know that import * is a bad idea.
Thank you,
- DD169