[PYTHON] class

class Person(object):
    def __init__(self, name):
        self.name = name
    
    def say_something(self):
        print('I am {}. Hello'.format(self.name))
        self.run(3)
    
    def run(self, num):
        print('run '*num)

person = Person('Tom')
person.say_something()

Execution result


I am Tom. Hello
run run run 

Recommended Posts

class
class
Class variables
Class variables
Class inheritance
Abstract class
[Python] class, instance
"Kanrika" python class
About python, class
Go class basics
Page processing class
Class method static method
Python class, instance
Proprietary exception class
JSON conversion class
#Python basics (class)
About Class and Instance
python syslog wrapper class
Python class (Python learning memo ⑦)
parallelization of class method
case class in python
Write decorator in class
[Python] Class inheritance (super)
Python self-made class sort
[Python] Class inheritance, override
python subprocess wrapper class
One Class SVM implementation
YOLO Python wrapper class
Class notation in Python
Python exception class list