Making a lazy attribute PREMIUM

Topic Series: Properties

Trey Hunner smiling in a t-shirt against a yellow wall
Trey Hunner
3 minute read
Python Morsels
Watch as video
02:35

In Python, you can make an attribute that doesn't exist until it's accessed.

Doing lots of work in the __init__ method

Here we have a FileStats class which accepts a filename:

``...

Write more Pythonic code

Need to fill-in gaps in your Python skills? I send regular emails designed to do just that.