python – convert tab’s in spaces


python is a nice language for programming, but recently we engaged a problem with tabs and      spaces.

you guessed right – there was emacs and vim users on the project with different coding rules in there configs 🙂

to fix the problem of this mixture of tabs and spaces, I used a bash one liner.

just change in your project directory and execute

for file in `find . -name “*.py“`; do expand –tabs=2 $file > $; mv $ $file; done

and for the other direction you can use “unexpand”


One Response to “python – convert tab’s in spaces”

  1. Natan Yellin Says:

    Just as a hint to anyone else who might want to use this, be sure to replace the html double quotes with normal double quotes. Simply copying and pasting the command will _not_ work otherwise.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: