How to call function from class in python, answer must be in links but dont get it
Question: Im using a function I downloaded somewhere however its not a function but a
class and I have no clue how to call it. This is aproximately how it looks,
say this is examplefile.py:

    
    
    class exampleclass:
      somevar = 1
    
      def func1(self, input):
        return input+somevar
    
      def func2(self, input):
        return input-somevar
    
    def main():
      hardvar = 2
      examp = exampleclass()
      out1 = examp.func1(hardvar)
      out2 = examp.func2(hardvar)
      print(hardvar,out1,out2)
    
    if __name__ == "__main__"
      main()
    

I just dont get how to use the functions inside of it. I tried

    
    
    import examplefile
    import exampleclass
    from examplefile import exampleclass
    

some of these do import the class, then I try calling it like this

    
    
    exampleclass.func1(1)
    

or

    
    
    exampinstance= exampleclass
    exampinstance.func1(1)
    

which both get me

    
    
    TypeError: unbound method ...() must be called with ... instance as first argument (got list instance instead)
    

and thats what never works, I looked at several questions
([such](http://stackoverflow.com/questions/17437837/error-unbound-method-
dragon-must-be-called-with-enemy-instance-as-first-argu)
[as](http://stackoverflow.com/questions/2417192/python-init-issue-unbound-
method-init-must-be-called-with-bank-instan?rq=1)
[these](http://stackoverflow.com/questions/4473184/unbound-method-f-must-be-
called-with-fibo-instance-as-first-argument-got-cla?rq=1)) here but I just
dont get how it works. Maybe you guys can see what Im not getting.


Answer: I call you to look at the following link. It may help:

[How to instantiate a class in
python](http://stackoverflow.com/questions/396856/how-to-instantiate-a-class-
in-python)

However you are nearly there. The code would look something like:

    
    
    exampinstance= exampleclass()
    exampinstance.func1(1)
    

Note the () at the end of the first line. You need to instantiate the class
properly. Note how the class is instantiated in the Main Method of the file
itself.

