At Saturday 20/1/2007 14:37, Siggi wrote:

> When I copy/paste Python code from the web, every so often,
> the TABs are wrong, which means that the code won't work and I have to
> manually reformat the code.
>
> Is there a code reformater that can parse the code to make it right?
>
> Thanks.

Maybe my thread "help: code formatter, 08/01/2007 helps a little? Here are
some of the answers:

*
Why don't you just write one? :)
Seriously: Try.
*
Tools\scripts\reindent.py in your Python distribution.
*
Why, yes, there is:
 http://lacusveris.com/PythonTidy/PythonTidy.python
*
tabnanny ?

As the indentation *is* significant in python, none of the above can help if you lose the indentation. Try to reconstruct this:

def foo():
if a>0:
if b>0:
print 1
print 2
else:
return 3
return 4

The tools may help to make the indentation consistent (tabs/8 spaces/4 spaces/2 spaces mixed) or look better, but not to make it right.


--
Gabriel Genellina
Softlab SRL

        

        
                
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to