Dear Users,
I'm using global values to create a unique ID, or name for each
instance of a class. If I import the following in one file and test it
it works fine. If the following class was imported in two different
files run by the same program would each instance of the class have a
unique name,
Wesley Brooks wrote:
Dear Users,
I'm using global values to create a unique ID, or name for each
instance of a class. If I import the following in one file and test it
it works fine. If the following class was imported in two different
files run by the same program would each instance of the
Luke Paireepinart wrote:
I believe that, if your program is importing 2 other packages, each of
which import some other package,
that other doubly-imported package will only be executed once, by
whichever one you import first.
Yes, that's right.
itemID = 0
class AssemblyItem:
def
Wesley Brooks wrote:
Dear Users,
I'm using global values to create a unique ID, or name for each
instance of a class. If I import the following in one file and test it
it works fine. If the following class was imported in two different
files run by the same program would each instance of
Thanks for your help I tested what you two said as follows and it
worked great. Thank you.
(Bellow in file TEST_ClassID.py)
class AssemblyItem:
itemID = 0
def __init__(self):
self.ID = assemblyItem + str(AssemblyItem.itemID)
AssemblyItem.itemID += 1
def
Wesley Brooks wrote:
Thanks for your help I tested what you two said as follows and it
worked great. Thank you.
(Bellow in file TEST_ClassID.py)
class AssemblyItem:
itemID = 0
def __init__(self):
self.ID = assemblyItem + str(AssemblyItem.itemID)