Dec-13-2017, 12:02 AM
I thought by thinking out loud here I could get some clarity. I have been wondering for awhile why __init__ method was necessary think I am getting it.
but with __init__ method it acts a store place for the data I introduce from outside the class into the __init__ method which i then can transfer to other methods in the class. This seems to be a be for now a big benefit of using __init__ for me.
student = MyClass('keep','clean')
MyClass.method_one(student)
I know I am instating my object student, with MyClass but not what the () area is called where 'keep','clean' are which I would call arguments or parameters and then the re-introduction of my object into my class connected to a method within the class ->MyClass.method_one(student)..Sorry if not clear as I am not clear yet on object oriented programming.
class MyClass: def method(self): return 'instance method called', self @classmethod def classmethod(cls): return 'class method called', cls @staticmethod def staticmethod(): return 'static method called' obj = MyClass() print(obj.method())it seemed only way I could interact with object or methods inside and introduce data was like above.
but with __init__ method it acts a store place for the data I introduce from outside the class into the __init__ method which i then can transfer to other methods in the class. This seems to be a be for now a big benefit of using __init__ for me.
class MyClass: def __init__(self,yo,yawn ): self.yo = yo self.yawn = yawn def method(self): return 'insatance method called', self def method_one(self): return 'boss'+ self.yo + self.yawn def classmethod(cls): return 'class method called', cls def staticmethod(): return 'static method called' student = MyClass('keep','clean') print(MyClass.method_one(student))I am interested in getting terminology down for these aspects of the code so I can research more on my own.
student = MyClass('keep','clean')
MyClass.method_one(student)
I know I am instating my object student, with MyClass but not what the () area is called where 'keep','clean' are which I would call arguments or parameters and then the re-introduction of my object into my class connected to a method within the class ->MyClass.method_one(student)..Sorry if not clear as I am not clear yet on object oriented programming.