title: Is there a name for the property of Python objects to have a console representation equivalent to their code?
body: <p>This is somewhat of a broad topic, but I will try to pare it to some specific questions.</p>
  <p>I was thinking about a certain <em>~meta~</em> property in Python where the console representation of many basic datatypes are equivalent to the code used to construct those objects:</p>
  <pre><code>l = [1,2,3]
  d = {'a':1,'b':2,'c':3}
  s = {1,2,3}
  t = (1,2,3)
  g = &quot;123&quot;
  
  ###
  
  &gt;&gt;&gt; l
  [1, 2, 3]
  &gt;&gt;&gt; d
  {'a': 1, 'b': 2, 'c': 3}
  &gt;&gt;&gt; s
  {1, 2, 3}
  &gt;&gt;&gt; t
  (1, 2, 3)
  &gt;&gt;&gt; g
  '123'
  </code></pre>
  <p>So for any of these objects, I could copy the console output into the code to create those structures or assign them to variables.</p>
  <p>This doesn't apply to some objects, like functions:</p>
  <pre><code>def foo():
      pass
  
  f = foo
  L = [1,2,3, foo]
  
  ###
  
  &gt;&gt;&gt; f
  &lt;function foo at 0x00000235950347B8&gt;
  &gt;&gt;&gt; L
  [1, 2, 3, &lt;function foo at 0x00000235950347B8&gt;]
  </code></pre>
  <p>While the list <code>l</code> above had this property, the list <code>L</code> here does not; but this seems to be only b/c <code>L</code> <em>contains an element which doesn't hold this property</em>.  So it seems to me that generally, <code>list</code> has this property in some way.</p>
  <p>This applies to some objects in non-standard libraries as well:</p>
  <pre><code>import numpy as np
  a = np.array([1,2,3])
  
  import pandas as pd
  dr = pd.date_range('01-01-2020','01-02-2020', freq='3H')
  
  ###
  
  &gt;&gt;&gt; a
  array([1, 2, 3])
  &gt;&gt;&gt; dr
  DatetimeIndex(['2020-01-01 00:00:00', '2020-01-01 03:00:00',
                 '2020-01-01 06:00:00', '2020-01-01 09:00:00',
                 '2020-01-01 12:00:00', '2020-01-01 15:00:00',
                 '2020-01-01 18:00:00', '2020-01-01 21:00:00',
                 '2020-01-02 00:00:00'],
                dtype='datetime64[ns]', freq='3H')
  </code></pre>
  <p>For the <code>numpy</code> array, the console output matches the code used, provided you have <code>array</code> in the namespace.  For the <code>pandas.date_range</code>, it's a little bit different because the console output can construct the same object produced created by <code>dr = pd.date_range('01-01-2020','01-02-2020', freq='3H')</code>, but with different code.</p>
  <h2>Interesting Example</h2>
  <p>A <code>DataFrame</code> doesn't hold this property, <em>however</em> using the <code>to_dict()</code> method <em>converts it into a structure which does hold this property</em>:</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame({'A':[1,2,3],
                     'B':[4,5,6]})
  
  ###
  
  &gt;&gt;&gt; df
     A  B
  0  1  4
  1  2  5
  2  3  6
  &gt;&gt;&gt; df.to_dict()
  {'A': {0: 1, 1: 2, 2: 3}, 'B': {0: 4, 1: 5, 2: 6}}
  &gt;&gt;&gt; pd.DataFrame.from_dict({'A': {0: 1, 1: 2, 2: 3}, 'B': {0: 4, 1: 5, 2: 6}})
     A  B
  0  1  4
  1  2  5
  2  3  6
  </code></pre>
  <p>An example scenario where this is useful is.....posting on SO!  B/c you can convert your DataFrame into a data structure where the text representation can be used to construct that data structure.  So if you share the <code>to_dict()</code> version of your DataFrame with someone, they are getting Python-syntaxed code which   can be used to recreate the structure.  I have found this to be advantageous over <code>pd.read_clipboard()</code> in some situations.</p>
  <hr />
  <h2>My questions based on the above:</h2>
  <p>Mainly:</p>
  <ul>
  <li>Is there a name for this &quot;property&quot; (given it is a real intentional &quot;property&quot; of objects in Python?)</li>
  </ul>
  <p>Additionally (these are less concretely answerable, I recognize, and can remove if off-topic):</p>
  <ul>
  <li>Is it something unique to Python or does it hold true in other languages?</li>
  <li>Are there other basic Python structures for which this property holds or doesn't hold?</li>
  </ul>
  <p>I apologize if this is common knowledge to people, or if I am making a mountain out of a molehill here!</p>