I have two files, both are in the same project (part of the structure of web clips). File1 processes items created using File2. In File2, I have a function that displays some basic statistics about processes (the number of attempts to create, etc.). I have an account in File1 that I would like to print using statistics from File1, but I'm not sure how to do this. Take a look at the sample code.
FILE 1:
class Class1(object):
def __init__(self):
self.stats = counter("name")
self.stats.count = 10
class counter:
def __init__(self, name):
self.name = name
self.count = 0
def __string__(self):
message = self.name + self.count
return message
FILE 2: (this is what I would like to do)
from project import file1
def stats():
print file1.Class1.stats
ERROR:
exceptions.AttributeError: type object 'Class1' has no attribute 'stats'
I know that both files are running, thus, an instance of the "stats" of the "counter" class, due to the fact that other methods are printed when the project starts (this is just a stripped-down example. Wrong? Is it possible to do this?