code indentation
...:::JA:::...
vedrandekovic at v-programs.com
Mon Jul 23 15:53:01 EDT 2007
Hello,
In my previously post I have been talk about running code with exec in......
So now I have problem with code indentation, as Gabriel Genellina says:
>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.
So......how can I do this?????????????
I will appreciate any help!!!!!
Regards,
Vedran
__________________________________________________________________ Vedran
veki ICQ#: 264412055 Current ICQ status: + More ways to contact me Get ICQ!
__________________________________________________________________
More information about the Python-list
mailing list