Referencing Python classes in same module

In Python you can create instances of classes defined in separate modules (scripts), as well as of classes that are defined in the same module.

Here is an example that demonstrates that this works both “upwards” and “downwards”:

class A:
    def __init__(self, name):
        self.Name = name

class B:
    def __init__(self, name):
        self.Name = name
        self.PartA = A("parta")
        self.PartC = C("partc")
        
class C:
    def __init__(self, name):
        self.Name = name

b = B("bclass")

print(b.Name)
print(b.PartA.Name)
print(b.PartC.Name)

This returns the follow output:

bclass
parta
partc