title: How Can a function act like a descriptor?
body: <pre><code>def typed_property(name, expected_type):
      storage_name = '_' + name
  
      @property
      def prop(self):
          return getattr(self, storage_name)
  
      @prop.setter
      def prop(self, value):
          if not isinstance(value, expected_type):
              raise TypeError('{} must be a {}'.format(name, expected_type))
          setattr(self, storage_name, value)
      return prop
  
  
  class Person:
      name = typed_property('name', str)
      age = typed_property('age', int)
      def __init__(self, name, age):
          self.name = name
          self.age = age
  
  </code></pre>
  <p>Function typed_property() acts like a descriptor. Why prop() is called when executing this code line (name = typed_property('name', str))?</p>