auto indent

M

M.N.Smadi

Hi there;

i have a script that is not indented properly. Is there a way that i can
have it auto indented.

thanks
moe smadi
 
L

Larry Bates

M.N.Smadi said:
Hi there;

i have a script that is not indented properly. Is there a way that i can
have it auto indented.

thanks
moe smadi

Not really. Indention in python conveys blocks so there is no way
anything automatic could determine where blocks end. Its just like
asking if you could have something automatically insert parenthesis
everywhere they are needed.

-Larry
 
L

Larry Bates

M.N.Smadi said:
Hi there;

i have a script that is not indented properly. Is there a way that i can
have it auto indented.

thanks
moe smadi

Not really. Indention in python conveys blocks so there is no way
anything automatic could determine where blocks end. Its just like
asking if you could have something automatically insert parenthesis
everywhere they are needed.

-Larry
 
J

John Henry

M.N.Smadi said:
Hi there;

i have a script that is not indented properly. Is there a way that i can
have it auto indented.

thanks
moe smadi

It depends what exactly you mean. I use Textpad and they have an
"indent selected block" feature.
 
J

John Machin

M.N.Smadi said:
Hi there;

i have a script that is not indented properly. Is there a way that i can
have it auto indented.

It depends on what you mean by "not indented properly". Indentation is
part of the Python grammar.

If the script compiles OK, and works as expected, but you have (say)
4-space indent in parts, and 3-space in other parts, or a mixture of
tabs and spaces, you could use the supplied reindent script. It's
C:\Python25\Tools\Scripts\reindent.py on my machine. Do read the
documentation at the start of the script before you run it.

If you mean that the indentation is just plain wrong, such that the
script will not compile without error, or incorrect indentation of one
or more lines is causing incorrect results, then you will have to fix
it manually. There is no "artificial intelligence" that can work out
what the indentation should be.

HTH,
John
 
J

jussij

M.N.Smadi said:
i have a script that is not indented properly. Is there
a way that i can have it auto indented.

FWIW the Zeus for Windows IDE will fold Pyhon code:

http://www.zeusedit.com/features.html

With the code folded you can then select the folded line and
using 'tab'/'shift tab' Zeus will indent/re-indent all the
lines contained in the fold.

It is not an automatic re-indenting solution but it might be
better than nothing ;)

Jussi Jumppanen
Author: Zeus for Windows IDE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top