Convert arbitrary function inputs to string

Ian ian.g.kelly at gmail.com
Thu Jan 6 11:53:54 EST 2011


On Jan 6, 9:42 am, David Dreisigmeyer <dwdreisigme... at gmail.com>
wrote:
> Yes,  I'm calling Gambit-C from Python and would like to make this
> cleaner.  Instead of having to do something like:
>
> gambit.eval ("(print \"Hello\n\")")
>
> I want to do this:
>
> gambit.eval (print "Hello\n")
>
> so that the expression following gambit.eval is a standard scheme expression.

That's much clearer.  As I indicated in my previous email, there is no
way to do this in Python.  You might try using a raw multi-line string
literal to reduce the amount of escaping you need to do.  So this:

"(print \"Hello\\n\")"

becomes this:

r"""(print "Hello\n")"""

Cheers,
Ian



More information about the Python-list mailing list