Why can't I see the arguments to the print function imported from future?
<p>I noticed that I cannot use flush with the new python function after I import it using <code>from __future__ import print_function</code>. In my journey to discover why I discovered I can't even inspect what arguments/parameters it takes. Why is it?</p>

<ol>
<li>First I made sure that the inspect function worked.</li>
<li>Then I made sure that the print function was indeed a function.</li>
<li>After those two (seemed to pass/check) I tried to inspect it but this failed and returned a weird error.</li>
</ol>

<p>here is what I did:</p>

<pre><code>from __future__ import print_function

import inspect

def f(a, b=1):
    pass

#print( print_function )
print( inspect.getargspec( f ) )
g = print
print('what is print: ', print)
print('what is g=print: ', g)
print( inspect.getargspec( g ) )
#print( inspect.getargspec( print ) )

#print('Hello', flush=True)
</code></pre>

<p>and everything passed except inspecting print:</p>

<pre><code>ArgSpec(args=['a', 'b'], varargs=None, keywords=None, defaults=(1,))
what is print?  &lt;built-in function print&gt;
what is g=print?  &lt;built-in function print&gt;
Traceback (most recent call last):
  File "print_future.py", line 16, in &lt;module&gt;
    print( inspect.getargspec( g ) )
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 816, in getargspec
    raise TypeError('{!r} is not a Python function'.format(func))
TypeError: &lt;built-in function print&gt; is not a Python function
</code></pre>

<p>Why is that happening?</p>

<hr>

<p>This is some info of my python and system:</p>

<pre><code>Python 2.7.11 (default, Jun 24 2016, 21:50:11)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt;
</code></pre>

<p>Extracted from <a href="https://funcsigs.readthedocs.io/en/0.3/#signature" rel="nofollow">signature</a>:</p>

<blockquote>
  <p>Note</p>
  
  <p>Some callables may not be introspectable in certain implementations of
  Python. For example, in CPython, built-in functions defined in C
  provide no metadata about their arguments.</p>
</blockquote>

<p>I've posted the signature docs because <a href="https://docs.python.org/3/library/inspect.html#inspect.getargspec" rel="nofollow">inspect.getargspec</a> is deprecated since 3.0</p>

python python-2.7 python-3.x printing