Jamie Riotto schrieb: > I have an app that uses Python scripting. When a user creates a new object: > > objName = newObject() > > I'd like the newObject be able to use objName as its internal name. > So, if a user says: > > cube1 = Cube() > > A "cube1" object should apear in the scene list. I believe this means I need > to determine that a namespace assignment is going on from inside the > object's init code > or by using properties.
As the others already explained to you there is no way to archive your goal with an assignment to a local or global variable. But you can follow a different approach: class Scene(object): def __setattr__(self, name, value): super(Scene, self).__setattr__(name value) if isinstance(value, SceneObject): value.name = name value.scene = self class SceneObject(object): pass class Cube(SceneObject): pass scene = Scene() scene.cube1 = Cube() Have fun! Christian -- http://mail.python.org/mailman/listinfo/python-list