(aka. A Quine So Clever It’s Cheating)
# doesn't work in Python 3.9+
import inspect, __main__
print(inspect.getsource(__main__), end="")
(there should be a newline at the end btw)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/inspect.py", line 1024, in getsource
lines, lnum = getsourcelines(object)
File "/usr/lib/python3.9/inspect.py", line 1006, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib/python3.9/inspect.py", line 817, in findsource
file = getsourcefile(object)
File "/usr/lib/python3.9/inspect.py", line 697, in getsourcefile
filename = getfile(object)
File "/usr/lib/python3.9/inspect.py", line 660, in getfile
raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module '__main__' (built-in)> is a built-in module