On Wednesday 10 June 2009 08:07:23 Stefan Behnel wrote:
> Hi,
>
> Dag Sverre Seljebotn wote:
> > Sebastien Binet wrote:
> >> Just for fun and to see how cython works, I am trying to write a
> >> CythonInterpreter inheriting from the usual code.InteractiveConsole.
>
> Way cool. I always wanted something like that for quickly checking out code
> snippets without going all the way through writing a module and
> pyximporting it.
>
> >> So far so good, I manage to compile cython-oneliners (leveraging
> >> pyximport.load_module) but then I'd need some help for multi-lines
> >> statements:
> >> ## ex:
> >> cdef class Foo:
> >>   pass
> >> ##
> >>
> >> for this to work in a reasonnable timely fashion, I'd need to see if
> >> parsing the snippet of code is valid cython (without compiling).
>
> The current parser isn't made for parsing things interactively, so I have
> no idea if this is trivial or hard to do.
>
> You might get away with checking for parser errors that indicate a missing
> indentation after the last character that you passed. Every parse error
> inside or before the last line would indicate a 'real' parser error.

thanks for the hint.
So I am now able to successfully enter at the cython prompt:
cython> cdef class Foo:
...              cdef int i

yeah!

the problem I get now is that I am out of luck if I want to actually do:
cdef class Foo:
  cdef int i
  cdef int j

as the class Foo is compiled just after I entered "cdef int i"...
I suppose I would have to know the indentation context of the last statement 
(if indent_lvl>0, gimme a new line)

hum... maybe I am not tackling this from the correct angle (perhaps that a 
simple buffer of strings filled while the last entry is not the_empty_string 
would do as I quick hack...)

cheers,
sebastien.
-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to