Is this possible in Python?
Paul Rubin
http
Mon Mar 13 03:37:25 EST 2006
alainpoint at yahoo.fr writes:
> assert magic_function(3+4)=="3+4"
> assert magic_function([i for i in range(10)])=="i for i in range(10)]"
>
> It is not trivial at all and might require some bytecode hacking that i
> am unable to do myself BUT you are the experts ;-)
Guhhh... you'd want to use the traceback system and reach back into
the source code to get and parse the statement that called the magic
function, sort of like a debugger does. I don't think messing with
the bytecode would help.
More information about the Python-list
mailing list