0

I have a Python code of about a thousand lines, contained in a .py file, and I would like to fix, possibly automatically, the indentation (i.e. at the first level four characters, then eight, and so on, as the standard requires).

To explain myself better, the code is correct and it works, but some parts are indented 2 characters, some 3, and some 4. I am trying to do this with BBedit, of which I have the pro version (the paid one).

I don't know if this is the right way but I use “Markup > Utilities > Format” and I always get an error:

Unespected EOF; Document ended in the middle of a tag.

Maybe I'm not using the right function?

Are there ways to get this result?

enter image description here

1 Answer 1

0

In order to reformat automatically Python code, use the black formatter. In can be used directly from the command line or from a Python IDE that accepts 'black' as a plugin.

An alternative to just reindent the code is the reindent script, an old tool but kept up-to-date by maintainers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .