creating a new class in python code example
Example 1: classes in python
class Foo:
def __init__(self):
self.definition = Foo!
def hi():
# Some other code here :)
# Classes require an __init__ if you want to assign attributes. (self) defines what describes the attribs.
Example 2: python class
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def myfunc(self):
print("Hello my name is " + self.name +".")
p1 = Person("Victor", 24)
p1.myfunc()