call a public property on an instance of a class in python

To call a public property on an instance of a class in Python, you first need to create an instance of that class. Then, you can access the property using dot notation.

Here's an example:

main.py
class MyClass:
    def __init__(self):
        self.my_property = "Hello, world!"

my_instance = MyClass()

print(my_instance.my_property)
139 chars
8 lines

In this example, we define a class MyClass with a public property my_property. When we create an instance of this class my_instance, we can access the property using dot notation.

The output of this code will be:

main.py
Hello, world!
14 chars
2 lines

gistlibby LogSnag