python attribute error code example

Example 1: attribute error python

# If python gives that error , 
# It means that whatever module doesn't have that specific function
# Therefore it can't run that specific function
# Example (recreating the error)

class Thing(object):
    
    def func(self):
        print("Random function was ran from class Thing().")

some_object = Thing()
# This will run properly
some_object.func()
# This won't run and produce the AttributeError.
some_object.some_func()

Example 2: AttributeError

AttributeError

Tags:

Misc Example