I would like to keep a reference of the objects I’ve created in one script to use them in another script (without using shelve).
I would like something close to :
script 1
class Porsche(Car):
""" class representing a Porsche """
def __init__(self, color):
self.color = color
class Porsche_Container:
# objects here
return objects
my_Porsche = Porsche(blue)
my_Porsche2 = Porsche(red)
script2
for object in Porsche_Container:
print object.color
rgds,
The best way to do this is explicitly to construct the set of objects that you want to access. It is possible to list e.g. all global variables defined in the other script, but not a good idea.
script1script 2