0

I have two Python files.

second.py:

class Exame:
   def on(self):
      # Some Code here
   def tw(self):
      # some code run

first.py:

from second.py import Exame
Exam.on()

In first.py when I call on method in second.py file I get error "missing 1 required positional argument: 'self'"

how can I solve this problem?

S.B
  • 13,077
  • 10
  • 22
  • 49
Sam
  • 35
  • 2
  • 8
  • 2
    Did you mean: `e = Exame(); e.on()`? – quamrana Feb 25 '22 at 18:20
  • 2
    `on` is an instance method, and you haven't created an instance. Do `Exam().on()`, or `exam = Exam()` and then `exam.on()`. – Samwise Feb 25 '22 at 18:20
  • 1
    Alternatively, define `on` as a class method or static method. If you don't know what these are, you should go through a tutorial on classes. Please read [how much research](//meta.stackoverflow.com/a/261593/843953). Your question has already been asked and answered, you just need to google the error message. – Pranav Hosangadi Feb 25 '22 at 18:22

0 Answers0