I want to set up a property only if requested explicitly. As this property will involve extra computation time, I want it initialized with None and only initializing if a calling function requests to do so.
For example:
class File:
def __init__(self, filename, content):
self.filename = filename
self.content = content
self.hash = None or self.get_hash()
def get_hash():
'''do some hashing there'''
I have seen some property of that kind but don't know how this could work trigger the function by calling:
my_file = File('text.txt', 'Hello there')
my_file.hash