'Python, self.alpha = alpha ran in function, but not found when calling self.alpha in its class

This is pretty weird since I have no idea what should I call this error.

So basically, I'm trying to input the file from another module

file1 (Input)

from file2 import Module2   

class Module1():
    def app_name(self,name):
        p = Module2()
        p.app_name(name)

    def app_directory(self,directory):
        p = Module2()
        p.app_directory(directory)
        
m = Module1()
m.app_name("app")
m.app_directory("path/to/app")

file2 (getting)

class Module2():
    def __init__(self):
        self.name = None
        self.directory = None
        
    def app_name(self,name):
        self.name = name
        
    def app_directory(self,directory):
        self.directory = directory
        self.pr()
    
    def pr(self):
        print(self.name,self.directory)

After being executed, It gave me self.name = None just like what it is in init, but self.directory is what I typed in. I spent hours but still can't figure out what is the problem, I really need help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source