funk-shun
funk-shun

Reputation: 4421

How to call method from inside a method?

class A:
  def a(self):
    print 'a'
  def b(self):
    print 'b'
    a()

Upvotes: 1

Views: 347

Answers (1)

unutbu
unutbu

Reputation: 880937

Class methods need their first argument to be self. You can then call the a method with self.a():

class A:
  def a(self):
    print 'a'
  def b(self):
    print 'b'
    self.a()

Upvotes: 7

Related Questions