A note about the Person class.
Below, let's create a Person class.
class Person:
#Initial setting
def __init__(self, name,company,age):#self is necessary for the time being
self.name = name
self.company = company
self.age = age
def say_hello(self,name):#self is necessary for the time being
print("Hello{}Mr. I{}is.".format(name, self.name))
def __call__(self, name):#self is necessary for the time being
print("Hello{}Mr. I{}is.".format(name, self.name))
-------------------------------------------------------
Suzuki = Person("Suzuki","ABC Trading",45)
Suzuki.name
#Suzuki
Suzuki.say_hello("Kato")
#Hello Mr. Kato. I'm Suzuki.
Suzuki("Tanaka")
#Hello Mr. Tanaka. I'm Suzuki.
#call function is Suzuki.__call__("Tanaka")You don't have to (this is possible but not appropriate)
Recommended Posts