robin hankin wrote:
Hi, debian linux, Sage-6.2.It took me some time to track down a problem in my code that boiled down to the interpretation of a caret ("^") in a file which was read using load() in a sage session. Specifically, I have a file called "f.py" which contains a single line, "o = 10^6". I load() this file, expecting o to be 1000000, but instead it takes the value 12. This is , I think, the result of a bitwise xor operation. But it is not what I wanted. sage: !cat f.py o = 10^6 sage: load("f.py") sage: o 12 sage: Note that in interactive mode, the caret is interpreted as expected: sage: o = 10^6 sage: o 1000000 sage: Is this a bug?
No. '^' means bitwise exclusive-or in Python, where exponentiation is (just) '**'.
Can anyone advise? I am very very very reluctant to adopt the ghastly "**" notation.
If you want your file to get preparsed (such that the Sage preparser replaces '^' by '**' "internally" when you load or run the file with 'sage'), simply rename your file to "f.sage".
Similar holds for '.pyx' vs. '.spyx'; the latter first gets preparsed. -leif -- () The ASCII Ribbon Campaign /\ Help Cure HTML E-Mail -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
