473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

exec - return value of expression

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQBALV1mfx2/njzvX5URApX5AJ0cG9CzO/jCQ6iB9bvsNvfm+z1xHQCfb1sp
4Z90gpZPZadJcnMSsueMHWA=
=fBd6
-----END PGP SIGNATURE-----
Jul 18 '05 #1
2 3657
> One solution would be to change the __repr__-Methods of the objects
which are to be prettyprinted. This should work, but I would like to
prettyprint some builtin objects too, like a list of formulas for
example. And I don't know how to change the __repr__ of builtin
lists.
Here's a kludge...if you are willing to manually instantiate all lists
first.
_list = list
class list(_list): .... def __repr__(self):
.... orig = _list.__repr__(self)
.... return "blah "+orig
.... a = list()
a blah [] a.append('hello')
a blah ['hello'] a.extend(['world', 'blah'])
a

blah ['hello', 'world', 'blah']
Any hints on how to solve this Problem in an elegant way are greatly
appreciated.


It is not elegant, but it may work for you.

- Josiah
Jul 18 '05 #2
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

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tedsuzman | last post by:
----- def f(): ret = 2 exec "ret += 10" return ret print f() ----- The above prints '12', as expected. However,
1
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
2
by: Chip Mayan | last post by:
Hello, I am fairly new at stored procedures. I have created some that will go through a table and return a start date and an end date that is dependent upon the fiscal period you want, but I...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
8
by: R. Bernstein | last post by:
In doing the extension to the python debugger which I have here: http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827 I came across one little thing that it would be nice...
4
by: Schüle Daniel | last post by:
Hello group, >>> lst= >>> for i in range(10): .... lst.append(eval("lambda:%i" % i)) .... >>> lst() 0 >>> lst() 1
9
by: gelangov | last post by:
I have 2 variables, one is the column name of the table and the other one is the table name and I need to write this in the "Execute SQL task" of a "For each loop" container in a ssis package like...
26
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour....
0
by: Stef Mientki | last post by:
Terry Reedy wrote: The locals of the code block where the instance of this class is created. No I think it's indeed handled as function call. I now that, because the globals (and sometimes ??? the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.