On Mon, Aug 10, 2009 at 11:08 AM, Dorian Raymer <deldo...@gmail.com> wrote:
> Evaluating Kiran's CELL 1 in a codenode python notebook returns a similar > error: > > File "<input>", line 1 > u = 2+3 > ^ > IndentationError: unexpected indent > > I don't think this is a sign of any bug, it is simply bad Python syntax. It > doesn't make sense to exec something with leading white space with no > preceding lines. > > One interesting clue to add to William's investigation... If you strip the > leading white space of the first line, and evaluate in codenode, you get > this: > > CELL 1: > 2+2 > 2+3 > > OUTPUT 1: > 4 > File "<input>", line 1 > 2+3 > ^ > IndentationError: unexpected indent > > > In the sage notebook, the output of the same input is "4" *without* the > IndentationError statement, the same as the result in question (when the > first line has 3 initial white spaces). > > This must have to do with sage pre-parsing out the white space of the > initial line. In codenode, valid command blocks are built up (similar to > sage, have look at > _runcommands<http://github.com/codenode/codenode/blob/cf5bc117fa7e1312426b7c1c134b59ca47203a83/codenode/backend/kernel/engine/python/interpreter.py#L102>if > you want). A cell may contain one or more valid commands. The interpreter > processes the input looking for complete commands to compile. Once it has a > complete command, it pauses processing the raw input, execs that command, > and then resumes processing the raw input until it has all been compiled and > exec'd. > Very nice. So in codenode does the following display the output of counting to 10 twice? (Sorry for being lazy.) CELL 1: for i in range(10): i for i in range(10): i OUTPUT 1: ?? I think what you're doing is better than what sagenb does... William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---