exec - return value of expression
Peter Otten
__peter__ at web.de
Thu Feb 19 04:31:05 EST 2004
Christoph Groth wrote:
> Currently, if the user wants to print some formula, say, he has to
> execute a function called `tex' which packages the TeX-representation
> of the formula in a way understood by texmacs, like this:
>
>>>> f = create_some_formula()
>>>> tex(f) # Prettyprint the formula
>
> But typing tex( ) all the time is a bit annoying, I would like that
> the following works inside my texmacs-plugin.
>
>>>> f = create_some_formula()
>>>> f # Prettyprint the formula
Have a look at sys.displayhook:
>>> import sys, __builtin__
>>> def myhook(a):
... if a is not None:
... __builtin__._ = a
... sys.stdout.write("python proudly presents: %s\n" % a)
...
>>> sys.displayhook = myhook
>>> 1
python proudly presents: 1
>>>
Peter
More information about the Python-list
mailing list