Skip to content

Instantly share code, notes, and snippets.

@abs51295
Created October 29, 2018 12:25
Show Gist options
  • Save abs51295/48e3c44473455c25875720fa53d502b6 to your computer and use it in GitHub Desktop.
Save abs51295/48e3c44473455c25875720fa53d502b6 to your computer and use it in GitHub Desktop.
canonicalize name
import re
_canonicalize_regex = re.compile(r"[-_.]+")
def canonicalize_name(name):
# This is taken from PEP 503.
return _canonicalize_regex.sub("-", name).lower()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment