0

I have a class that calls upon another class to use it's function

main.py
--------------------
class MyClass():

    def main(self, arg):
        from lib.otherclass import OtherClass
        otherClass = OtherClass() 

        result = otherClass.prepare.importImage(image)


myClass = MyClass()
final = myClass(image)

I get this error

importImage() takes 1 positional argument but 2 were given

This is what the other class looks like:

class OtherClass():
    def __init__(self):
        self.prepare = Prepare()

class Prepare():

    def importImage(image):
        blah blah blah

How do I fix this?

Cristian
  • 495
  • 2
  • 9
  • 35

1 Answers1

3

either:

class Prepare():

    def importImage(self, image):

or:

class Prepare():

    @staticmethod
    def importImage(image):

see python takes 1 positional argument but 2 were given and What is the purpose of self?

Sebastian Loehner
  • 1,302
  • 7
  • 5