Whoops...Sorry about the address foul-up. Not sure how the old
'sf.net' addresses crept back in.
On Feb 3, 2007, at 12:48 , William Stein wrote:
> On Sat, 03 Feb 2007 13:30:14 -0800, David Joyner
> <[EMAIL PROTECTED]> wrote:
>
>> This is more pythonic, but: is it possible to create a string that is
>> a well-formed argument to 'print', so that 'print' will print what
>> that argument dictates?
>> My naive attempts have not worked, and I am wondering whether it can
>> be done.
>> This is the sort of thing I'm shooting for:
>> s1 = '\"%s\"%6'
>> print s1
>> I'd like something other than '"%s"%6' to show up :=}
>
> No. But instead you could do print eval(s1):
>
> sage: s1 = '\"%s\"%6'
> sage: s1
> '"%s"%6'
> sage: print eval(s1)
> 6
Thanks! That is one thing I didn't try (eval('print s1') failed...).
Next domino: the Python syntax for strings is a bit obscure, but it
seems to be difficult to get newlines into a string for evaluation.
Is it possible? The various tricks I've tried have come to naught.
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Institute for the Absorption of Federal Funds
--------
Some people have a mental horizon of radius zero, and
call it their point of view.
-- David Hilbert
--------
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---