how to use functions in a class python code example
Example 1: python define class
class uneclasse():
def __init__(self):
pass
def something(self):
pass
xx = uneclasse()
xx.something()
Example 2: how to define a class in python
class a_class:
#This initalizes the object, and is executed when you define
#a new object in the class
def __init__(self, input1):
self.__input1 = input1
#This is a function of the object that can be called
def return_input(self):
return self.__input1
a_class_object = a_class("input string")
print(a_class_object.return_input())