Viktor Marohnic wrote:
I would to do something like this.
container = []
p1 = point()
l1 = line()
and i would like to override = method of the module so that its puts
all objects into container.
how i can do something like that.
you cannot, at least not as you've described the problem. assignment is not
an operator in Python; it's a statement that modifies the current namespace.
things you can do include
- use an explicit target object
x.p1 = point()
x.l1 = line()
- execute the script in a controlled fashion, and inspect the resulting namespace:
myscript = """
p1 = point()
l1 = line()
"""
# create a new namespace, and add "built-in" functions to it
namespace = {}
namespace["point"] = point
namespace["line"] = line
# execute the script in this namespace
exec myscript in namespace
for key, item in namespace.iteritems():
...
</F>