Re: Creating dynamic objects with dynamic constructor args

2008-03-25 Thread Robert Bossy
[EMAIL PROTECTED] wrote: > I'd like to create objects on the fly from a pointer to the class > using: instance = klass() But I need to be able to pass in variables > to the __init__ method. I can recover the arguments using the > inspect.argspec, but how do I call __init__ with a list of argu

Re: Creating dynamic objects with dynamic constructor args

2008-03-25 Thread Furkan Kuru
you can call a function with arglist like this: def dummy(a, b, c): print a + b, c args = [1, 2, "hello"] dummy(*args) On Tue, Mar 25, 2008 at 5:38 PM, <[EMAIL PROTECTED]> wrote: > I'd like to create objects on the fly from a pointer to the class > using: instance = klass() But I need to

Creating dynamic objects with dynamic constructor args

2008-03-25 Thread Greg
I'd like to create objects on the fly from a pointer to the class using: instance = klass() But I need to be able to pass in variables to the __init__ method. I can recover the arguments using the inspect.argspec, but how do I call __init__ with a list of arguments and have them unpacked to

Re: Dynamic objects

2006-08-17 Thread Larry Bates
Mark Shewfelt wrote: > Hello, > > I have implemented a series of classes representing a Building, its > respective Equipment, and then various Components of that equipment > like so (as you'll be able to tell, I'm a newbie): > > class Building: > equipment = {} > def AddEquipment( name,

Re: Dynamic objects

2006-08-17 Thread Mark Shewfelt
Thanks a lot Tim! My __init__ functions didn't set the dictionaries like you did below (e.g. self.equipment = {} ). Newbie mistake - won't make that one again. Thanks again, Mark Tim wrote: > Mark Shewfelt wrote: > > Hello, > > > > I have implemented a series of classes representing a Buildin

Re: Dynamic objects

2006-08-17 Thread Tim
Mark Shewfelt wrote: > Hello, > > I have implemented a series of classes representing a Building, its > respective Equipment, and then various Components of that equipment > like so (as you'll be able to tell, I'm a newbie): > > class Building: > equipment = {} > def AddEquipment( name,

Dynamic objects

2006-08-17 Thread Mark Shewfelt
Hello, I have implemented a series of classes representing a Building, its respective Equipment, and then various Components of that equipment like so (as you'll be able to tell, I'm a newbie): class Building: equipment = {} def AddEquipment( name, data ): equipment[ name ] =