Manuel Graune skrev:
To clarify, I just start an editor, write a file that
might look something like this:

---------snip-----
code="""
a = 1
b = 2
c = 3
result = a + b
"""
exec(code)
print(code)
print("result     =\t", result)
print("result + c =\t", result + c)
---------snip------

and feed this to python.


I do not understand your use-case, but as one way of performing the same task as the above code, without sacrificing syntax-highlighting, I would suggest:

-------------------------
from __future__ import with_statement
import sys

def print_source():
    print sys.argv
    with open(sys.argv[0]) as file:
        for line in file:
            print line,

a = 1
b = 2
c = 3
result = a + b

print_source()
print("result     =\t", result)
print("result + c =\t", result + c)

------------------------


Does that help towards a solution of your problem?

/ johan

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to