I have two files: client.py and ItemDatabase.py. I'm trying to store item values in a separate source file, similar to a database, and then call on those item values when I need them in other source files. Here I have the classes Item and WeaponData, which both hold information about the item, and then the instance itself is created in the ItemDatabase. When I want to get that information in the other source file through a print statement I am getting an error: NameError: name 'tinder_sword' is not defined, even though my IDE recognizes that tinder_sword is apart of ItemDatabase.
In client.py:
from ItemDatabase import *
import pygame as pg
class Item:
def __init__(self):
self.name = ""
self.description = ""
self.max_stack_size = 0
self.icon = ""
class WeaponData(Item):
def __init__(self):
super().__init__()
self.damage = 0
self.range = 0
self.cooldown = 0
self.max_condition = 0
self.max_stack_size = 1
print(tinder_sword.name)
In ItemDatabase.py:
from client import *
tinder_sword = WeaponData()
tinder_sword.name = "Tinder Sword"
tinder_sword.description = "Weak and flimsy, but it's not bad for a starter weapon."
tinder_sword.damage = 10
tinder_sword.cooldown = 0.2
tinder_sword.max_condition = 75