Created
April 10, 2013 14:44
-
-
Save Lucretiel/5355246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_variable_name(var): | |
valid_chars = set(string.letters + string.digits + '_') | |
def replace_char(char): | |
if char == '-': | |
return '_' | |
elif char in valid_chars: | |
return char | |
return '' | |
return ''.join(replace_char(char) for char in var) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment