Skip to content

Instantly share code, notes, and snippets.

@cosmin
Created April 26, 2011 11:55
Show Gist options
  • Save cosmin/942141 to your computer and use it in GitHub Desktop.
Save cosmin/942141 to your computer and use it in GitHub Desktop.
Example for turning a camelcase name into a _ separated filename.
def main(filename):
data = open(filename).read()
for char in range(65,91):
letter = chr(char)
data = data.replace(letter, '_' + letter.lower())
print data[1:].replace('\n_','\n').replace('_test','_test.rb')
if __name__ == "__main__":
import sys
filename = sys.argv[1]
main(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment