Skip to content

Instantly share code, notes, and snippets.

@alenbasic
Created May 22, 2013 02:31
Show Gist options
  • Save alenbasic/5624875 to your computer and use it in GitHub Desktop.
Save alenbasic/5624875 to your computer and use it in GitHub Desktop.
When helping a friend with his code I kept having issues modifying it because of tabs/spaces (my text editors convert tabs to spaces while his doesn't) so I created this script so that I could quickly convert his tabs to spaces.
import re; from sys import argv
# start the program like this:
# python tabs2spaces.py file_name_to_change.extension
file_name = argv[1]
read = open(file_name,'r+').read()
update = re.sub("[\t]", ' ', read)
save = open(file_name, 'w')
save.write(update)
save.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment