Code
# egz. of inheritance and use of super() function
class Fruit():
def __init__(self, name):
print(name)
class Apple(Fruit):
def __init__(self, name, color):
self.color = color
super().__init__(name) # egz. of inheritance and use of super() function
class Fruit():
def __init__(self, name):
print(name)
class Apple(Fruit):
def __init__(self, name, color):
self.color = color
super().__init__(name) As Python has no concept of private variables, leading underscores are used to indicate variables that must not be accessed from outside the class.
from typing import NamedTuple
class Transaction(NamedTuple):
sender: str
receiver: str
date: strdef make_pretty(func):
def inner():
print("I got decorated")
func()
return inner
@make_pretty
def ordinary():
print("I am ordinary")
# ordinary()
# Output:
# I got decorated
# I am ordinary