Created
December 30, 2016 12:34
-
-
Save dkapitan/af83dc060c47cb021ffcc93f7e2a71ec to your computer and use it in GitHub Desktop.
convert strings to Python format
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 to_python_string(string): | |
"""Replaces spaces with underscores, all characters lowercase""" | |
try: | |
return string.replace(' ', '_').lower() | |
except (ValueError, NameError, TypeError): | |
return string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment