Re: adding methods at runtime and lambda

2007-05-07 Thread Mike
On May 4, 5:46 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Mike wrote: > > I just realized in working with this more that the issues I was having > > with instancemethod and other things seems to be tied solely to > > What you describe below is a function that happens to be an attribute of an > in

Re: adding methods at runtime and lambda

2007-05-04 Thread Peter Otten
Mike wrote: > I just realized in working with this more that the issues I was having > with instancemethod and other things seems to be tied solely to What you describe below is a function that happens to be an attribute of an instance. There are also "real" instance methods that know about "thei

Re: adding methods at runtime and lambda

2007-05-04 Thread Mike
On May 4, 2:05 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Mike wrote: > > staticmethod makes the function available to the whole class according > > to the docs. What if I only want it to be available on a particular > > instance? Say I'm adding abilities to a character in a game and I want > > t

Re: adding methods at runtime and lambda

2007-05-04 Thread Peter Otten
Mike wrote: > staticmethod makes the function available to the whole class according > to the docs. What if I only want it to be available on a particular > instance? Say I'm adding abilities to a character in a game and I want > to give a particular character the ability to 'NukeEverybody'. I don

Re: adding methods at runtime and lambda

2007-05-04 Thread Mike
On May 3, 11:25 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 03 May 2007 16:52:55 -0300, Mike <[EMAIL PROTECTED]> escribió: > > > I was messing around with adding methods to a class instance at > > runtime and saw the usual code one finds online for this. All the > > examples I saw

Re: adding methods at runtime and lambda

2007-05-03 Thread Gabriel Genellina
En Thu, 03 May 2007 16:52:55 -0300, Mike <[EMAIL PROTECTED]> escribió: > I was messing around with adding methods to a class instance at > runtime and saw the usual code one finds online for this. All the > examples I saw say, of course, to make sure that for your method that > you have 'self' as

Re: adding methods at runtime and lambda

2007-05-03 Thread ici
On May 3, 10:52 pm, Mike <[EMAIL PROTECTED]> wrote: > I was messing around with adding methods to a class instance at > runtime and saw the usual code one finds online for this. All the > examples I saw say, of course, to make sure that for your method that > you have 'self' as the first parameter.

Re: adding methods at runtime and lambda

2007-05-03 Thread James Stroud
Mike wrote: > I was messing around with adding methods to a class instance at > runtime and saw the usual code one finds online for this. All the > examples I saw say, of course, to make sure that for your method that > you have 'self' as the first parameter. I got to thinking and thought > "I have

Re: adding methods at runtime and lambda

2007-05-03 Thread Mike
In the above example 'addm' should be 'AddMethod' superdict = AddMethod(dict(), lambda self, d: myUtils.HasDrive(d),"hasdrive") -- http://mail.python.org/mailman/listinfo/python-list

adding methods at runtime and lambda

2007-05-03 Thread Mike
I was messing around with adding methods to a class instance at runtime and saw the usual code one finds online for this. All the examples I saw say, of course, to make sure that for your method that you have 'self' as the first parameter. I got to thinking and thought "I have a lot of arbitrary me