[Tutor] Using class methods

Christopher King g.nius.ck at gmail.com
Tue Jun 21 16:03:10 CEST 2011


Well it depends what you mean. If you have a critter object and want
to invoke its method inside the farm, do somethinh like this.
class Farm_class(object):
  def feed(self, critter):
    critter.eat(self.food)

or if you want to use a method of the Critter class within the farm do

class Farm_class(object):
  def count(self):
    print Critter_class.count()

On Tuesday, June 21, 2011, Andre Engels <andreengels at gmail.com> wrote:
> On Tue, Jun 21, 2011 at 10:12 AM, David Merrick <merrickdav at gmail.com> wrote:
>> I need help using Class methods in another class. I have a class called
>> Critter and I want to create two critters in a farm  Class Farm and use
>> Class Critter's methods
>
> Could you please specify where your current code does not suffice -
> where does it something different than you want, or where do you want
> to do something (and why) that you don't know how to do?
>
> --
> André Engels, andreengels at gmail.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list