title: How to print a Python attribute name?
body: <p>Say I'd like to create an introspection stanza, that displays available details of a function. <br>Something like the bottom of the following code:</p>
  
  <pre><code>def sample(_range=4):
      """ produce a range of integers """
      for i in range(_range):
          yield i
  
  f = sample
  for i in (f.__name__, f.__doc__, f.__dict__, f.__code__, f.__defaults__, f.__globals__, f.__closure__):
      print("XXX", i)
  </code></pre>
  
  <p>What I'm failing to achieve is changing the <code>XXX</code> to something that would print the attribute name, e.g., instead of</p>
  
  <pre><code>XXX sample
  XXX  produce a range of integers
  XXX {}
  XXX &lt;code object sample at 0xfff15890, file "/tmp/tmp.py", line 1&gt;
  XXX (4,)
  XXX {'__loader__': &lt;_frozen_importlib.SourceFileLoader object at 0xfff13b30&gt;, '__package__': None, '__file__': '/tmp/tmp.py', '__cached__': None, 'i': {...}, 'f': &lt;function sample at 0xfff5b1e0&gt;, '__builtins__': &lt;module 'builtins' (built-in)&gt;, '__doc__': None, '__spec__': None, '__name__': '__main__', 'sample': &lt;function sample at 0xfff5b1e0&gt;}
  XXX None
  </code></pre>
  
  <p>I'd like to have</p>
  
  <pre><code>__name__ sample
  __doc__  produce a range of integers
  __dict__ {}
  __code__ &lt;code object sample at 0xfff15890, file "/tmp/tmp.py", line 1&gt;
  __defaults__ (4,)
  f.__globals__ {'__loader__': &lt;_frozen_importlib.SourceFileLoader object at 0xfff13b30&gt;, '__package__': None, '__file__': '/tmp/tmp.py', '__cached__': None, 'i': {...}, 'f': &lt;function sample at 0xfff5b1e0&gt;, '__builtins__': &lt;module 'builtins' (built-in)&gt;, '__doc__': None, '__spec__': None, '__name__': '__main__', 'sample': &lt;function sample at 0xfff5b1e0&gt;}
  __closure__ None
  </code></pre>
  
  <p>What would you suggest should replace <code>XXX</code>?</p>