Import class in same file in Python
Question: I'm new to python and I have a file with several classes. In a method in the
class "class1" I want to use a method from another class "class2". How do I do
the import and how do I call the method from class1? I have tried several
different things but nothing seems to work.


Answer: you dont need to import them becuase they are already in the same file

do something like this:

    
    
    class1 = Class1() #assigns class1 to youre first class
    

then call a method of Class1 like this:

    
    
    Class2():
        def method2(self):
            class1.method1() #call youre method from class2 
    

basically you are taking `Class2()` and giving it the instance `class2` then
you are calling a method of that class by doing `class2.method2()` its just
like calling a function but you need the class name in front of it

here is an example:

    
    
    class Class1():
    
        def method1(self):
            print "hello"
    
    class Class2():
        def method2(self)
            class1 = Class1()
            class1.method1()
    

then when you call `Class2()` it will print 'hello'

