I want to create a Python function that can inspect its own input, rather than the output of its input. For example, a function raw_str that returns its input exactly, as a string:
>>> raw_str(2+2)
'2+2'
rather than:
>>> str(2+2)
'4'
Is there any way to do this?
This is not possible because the arguments are evaluated before they are passed on to the function - so there will be no way to distinguish between 2 + 2
and 3 + 1
(for instance) within the function body. Without more context, it's hard to suggest possible solutions to the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With