Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28066

How to program test(expr) ?

From Franck Ditter <franck@ditter.org>
Newsgroups comp.lang.python
Subject How to program test(expr) ?
Organization SN distribution
Date 2012-08-29 17:04 +0200
Message-ID <franck-E4DC28.17040529082012@news.free.fr> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How to program test(expr) ? Franck Ditter <franck@ditter.org> - 2012-08-29 17:04 +0200
  Re: How to program test(expr) ? Terry Reedy <tjreedy@udel.edu> - 2012-08-29 17:35 -0400
  Re: How to program test(expr) ? Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 09:33 +0200

csiph-web