Convert arbitrary function inputs to string

David Dreisigmeyer dwdreisigmeyer at gmail.com
Thu Jan 6 11:42:23 EST 2011


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.
On Thu, Jan 6, 2011 at 11:34 AM, Jean-Michel Pichavant
<jeanmichel at sequans.com> wrote:
> David wrote:
>>>> Hi,
>>>> I'd like to have a function that takes arbitrary inputs and returns
>> them as a single string, with proper escapes for special characters I
>> can define.  For example:
>>>> fun( ( + 1 2 ) )
>> => "( + 1 2)"
>>>> or
>>>> fun(  (define (myhello str) (begin (print (string-append "Hello "
>> str)) (newline) )) )
>> =>  "(define (myhello str) (begin (print (string-append \"Hello \"
>> str)) (newline) ))"
>>>> Thanks,
>>>> -Dave
>>>> Are you talking about python ??
>> fun( ( + 1 2 ) )
>  File "<stdin>", line 1
>   fun( ( + 1 2 ) )
>              ^
> SyntaxError: invalid syntax
>>


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /