Prev: Revisiting Generators and Subgenerators
Next: Don't understand behavior; instance form a class in another class'instance
From: I V on 26 Mar 2010 16:46 On Fri, 26 Mar 2010 08:54:11 -0700, Michel wrote: > I want to add a method to a class such that it can be invoked on > specifics instances. > You solution works (as well as Patrick's one), thanks ! I still have a > question though. If I print the type of the self object I get when my > method is > called, I get "<class 'test.TestClass'>". I guess this is because the > method is defined as a class method. > This is ok in my case, but just out of curiosity, what should I do to > change this method to an instance method? It already is an instance method. When you create a TestClass instance, the type of that instance is TestClass (the type of TestClass itself is "type"). |