How would I call a function within a class from the same class in python?
Question: Given this basic example, but in reality it's more complex: (Name of the file
is TestFile)

    
    
    class Example:
        def test1():
            print("First test")
        def test2():
            print("Second test")
        def test3():
            #Call test1()
            #Call test2()
    

I've tried `Example.test1()` and `Example.test2()`, which works, but if
someone would do

    
    
    from TestFile import Example as MagicTrick
    

Wouldn't the final function break?


Answer: No, it won't break because of that sort of import. Using `as` to import
something under a different name only affects what it's called in the place
where it's imported. In your original file `TestFile`, the class will still be
called `Example` and can still refer to itself as such. In other words, using
`as` in the import just creates a "local alias"; it doesn't change any other
names the imported object might have referring to it.

In reality, you would typically call `self.test1()` in order to call the
method on an instance. That won't work for your example because you didn't
provide a `self` argument, but perhaps that was an oversight in your "basic"
example.

