F
Franck Ditter
Hi !
I use Python 3.2.3 + Idle.
Is it possible to program test(e) which takes
an expression e and whose execution produces
at the toplevel an echo of e and the effects
and result of its evaluation ?
# file foo.py
def foo(x) :
print('x =',x)
return x+1
test(foo(5))
# RUN !
# produces at the toplevel :
? foo(5)
x = 5
--> 6
I know I could put the expression e within a string, but
is it possible to avoid the string, like a Lisp macro ?
Thanks.
franck
I use Python 3.2.3 + Idle.
Is it possible to program test(e) which takes
an expression e and whose execution produces
at the toplevel an echo of e and the effects
and result of its evaluation ?
# file foo.py
def foo(x) :
print('x =',x)
return x+1
test(foo(5))
# RUN !
# produces at the toplevel :
? foo(5)
x = 5
--> 6
I know I could put the expression e within a string, but
is it possible to avoid the string, like a Lisp macro ?
Thanks.
franck