problem with exec
vedrandekovic at v-programs.com
vedrandekovic at v-programs.com
Mon Jul 23 06:00:16 EDT 2007
On 23 srp, 09:19, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Sun, 22 Jul 2007 10:36:59 -0300, <vedrandeko... at v-programs.com>
> escribió:
>
> >> Since the application is transforming
> >> its input, it could transform braces into indentation. Of course
> >> *Python*
> >> doesn't use braces, but the question was how to write "pseudo-Python"
> >> without using indentation to indicate grouping.
>
> > This previously is exactly what I need can you help me somehow about
> > this
> > code
> > indentation, on any way you know.Plese help I will really appreciate
> > this!!!!!!!!!!!!!!
>
> If you are using the tokenize module as suggested some time ago, try to
> analyze the token sequence you get using { } (or perhaps begin/end pairs
> in your own language, that are easier to distinguish from a dictionary
> display) and the sequence you get from the "real" python code. Then write
> a script to transform one into another:
>
> from tokenize import generate_tokens
> from token import tok_name
> from cStringIO import StringIO
>
> def analyze(source):
> g = generate_tokens(StringIO(source).readline)
> for toknum, tokval, _, _, _ in g:
> print tok_name[toknum], repr(tokval)
>
> I think you basically will have to ignore INDENT, DEDENT, and replace
> NAME+"begin" with INDENT, NAME+"end" with DEDENT.
>
> --
> Gabriel Genellina
Hello,
I know what do you mean and I really need that , but I don't know how
to I do this. Please help me!!!!! It's really important to me
Regards,
Vedran
More information about the Python-list
mailing list