import time from datetime import datetime class Time: def __get__(self, instance, owner_class): print('get access to __get__ method') print(f'self = {self}') print(f'instance = {instance}') print(f'owner_class = {owner_class}') return datetime.now().isoformat() ''' class Time: def __get__(self, instance, owner_class): if instance is None: return self else: return datetime.now().isoformat() # Тоже, но через свойства # @property # def current_time(self): # return datetime.now().isoformat() ''' class Logger: current_time = Time() # Есил current_time = @property # current_time = Time().current_time def main(): # log = Logger() # print(log.current_time) # time.sleep(2) # print(log.current_time) print(Logger.current_time) # log = Logger() # print(log.current_time) if __name__ == '__main__': main()