python – convert tab’s in spaces

by

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 > $file.new; mv $file.new $file; done

and for the other direction you can use “unexpand”

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s


%d bloggers like this: