On Sep 18, 1:00 pm, Jamie Riotto <jamie.rio...@gmail.com> wrote:
> 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.
>
> I've searched the web but can't find a simple answer. Is there some
> way to use the inspect
> module get source code functoins? How would I get the code for "the
> current interpreter line"
> causing the init code to execute?
>
> Thanks very much in advance,
> Jamie Riotto

Save yourself a lot of trouble and just assign a name "manually":

class foo:
    def __init__(self, name):
        self.name = name


some_foo = foo("some_foo")

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to