[Tutor] Global values import scope

2007-01-24 Thread Wesley Brooks
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,

Re: [Tutor] Global values import scope

2007-01-24 Thread Luke Paireepinart
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

Re: [Tutor] Global values import scope

2007-01-24 Thread Kent Johnson
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

Re: [Tutor] Global values import scope

2007-01-24 Thread Kent Johnson
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

Re: [Tutor] Global values import scope

2007-01-24 Thread Wesley Brooks
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

Re: [Tutor] Global values import scope

2007-01-24 Thread Kent Johnson
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)