I've seen this question:
How can I get the source code of a Python function?
But I can't find anything that works generically for built-in functions and user-defined functions.
eg, I try:
>>> print.__repr__()
'<built-in function print>'
and
>>> repr(print)
'<built-in function print>'
and
>>> print(print)
<built-in function print>
and
$ python
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19) 
>>> inspect.getsource(print)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.6/inspect.py", line 968, in getsource
    lines, lnum = getsourcelines(object)
  File "/home/user/anaconda3/lib/python3.6/inspect.py", line 955, in getsourcelines
    lines, lnum = findsource(object)
  File "/home/user/anaconda3/lib/python3.6/inspect.py", line 768, in findsource
    file = getsourcefile(object)
  File "/home/user/anaconda3/lib/python3.6/inspect.py", line 684, in getsourcefile
    filename = getfile(object)
  File "/home/user/anaconda3/lib/python3.6/inspect.py", line 666, in getfile
    'function, traceback, frame, or code object'.format(object))
TypeError: <built-in function print> is not a module, class, method, function, traceback, frame, or code object
How can I do this?
Update:
Duplication police: this isn't a duplicate. I'm obviously literally citing and acknowledging the question this is allegedly a duplicate of in the very first line of this question and asking for something expanding on that.
