Ask Your Question

jediknight219's profile - activity

2015-11-03 22:57:34 +0100 commented question Bug with raw literals?

On cloud.sagemath it works in a sage worksheet, but not a Jupyter notebook.

2015-11-03 21:55:38 +0100 answered a question Save boolean polynomial ring to file and read it again

Try this:

for i in range(1,257):
R = BooleanPolynomialRing(names=variables)
fw = open('/home/pro/Desktop/polynomials.txt', 'w')
polynomial = R.random_element(degree=2,terms=+infinity)
fw.write(repr(polynomial) + "\n")                      # replaced str with repr
fr = open('/home/pro/Desktop/polynomials.txt', 'r')
polynomial = eval(fr.readline())                       # added eval
2015-11-03 14:58:39 +0100 received badge  Self-Learner (source)
2015-11-02 20:35:04 +0100 answered a question Bug with raw literals?

Looks like it is a known IPython bug.

2015-11-02 19:59:31 +0100 commented question Bug with raw literals?

I'm on, running a Jupyter notebook, running the Python 2 kernel. I tried changing to Python 3, but to no avail.

2015-11-02 19:46:58 +0100 received badge  Student (source)
2015-11-02 19:44:11 +0100 commented question Bug with raw literals?

Apparently it only happens on the first line. The following works fine.

2015-11-02 19:20:49 +0100 received badge  Scholar (source)
2015-11-02 19:19:39 +0100 asked a question Bug with raw literals?

On cloud.sagemath, the following is interpreted as an empty string


According to the python docs, Section 2.4.1 of the language specification:: "Note also that a single backslash followed by a newline is interpreted as those two characters as part of the literal, not as a line continuation."

Is this a bug? Or am I missing something?

2015-10-28 20:42:07 +0100 received badge  Self-Learner (source)
2015-10-28 20:42:07 +0100 received badge  Teacher (source)
2015-10-28 19:36:12 +0100 answered a question Custom Input Transformation

Figured it out. Replaced logical_line_transforms with physical_line_transforms.

2015-10-28 19:23:44 +0100 received badge  Editor (source)
2015-10-28 18:58:34 +0100 asked a question Custom Input Transformation

Greetings. I am trying to emulate the << >> functionality of OCaml in python on For instance, if I type:


I want it to call default_parser("stuff"). I have it working if << and >> are on the same line, but I want it to be able to span multiple lines. Here's my code:

from IPython.core.inputtransformer import (StatelessInputTransformer)

def quotations(line):
    if line is not None:
        line = line.replace("<<", 'default_parser("""')
        line = line.replace(">>", '""")')
    return line

ip = get_ipython()

It can't handle this:


It replaces the << in the first line just fine, but apparently once it goes into triple quote mode, it stops calling my transformation function.