from collections import namedtuple

def checking_type_equality_bad():
    Point = namedtuple('Point', ['x', 'y'])
    p = Point(1, 2)

    if type(p) == tuple: # Liskov substitution violation
        print("it's a tuple")
    else:
        print("it's not a tuple")

def checking_type_equality_good():
    Point = namedtuple('Point', ['x', 'y'])
    p = Point(1, 2)
    # probably meant to check if is instance of tuple
    if isinstance(p, tuple):
        print("it's a tuple")
    else:
        print("it's not a tuple")

# Calling all the functions
checking_type_equality_bad()
checking_type_equality_good()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: