python call a function inside a class code example

Example 1: call a function from another class python

class A:
    def method1(arg1, arg2):
        # do code here

class B:
    A.method1(1,2)

Example 2: how to create a class inside a function in python

def create_class():
  class Person:
    def __init__(self, name, age):
      self.name = name
      self.age = age
      
  # returns the class NOT an instance of the class
  # instance would be Person()
  return Person

my_class = create_class()
person1 = my_class("John", 24)

print(f'{person1.name} is {person1.age} years old.')