Skip to content

Instantly share code, notes, and snippets.

@asfaltboy
asfaltboy / argparse_email_type.py
Created October 9, 2016 17:48
EmailType: a custom argparse type to validate email addresses
"""
A custom type for argparse, to facilitate validation of email addresses.
Inspired by this SO question: http://stackoverflow.com/questions/14665234/argparse-choices-structure-of-allowed-values
and this gist: https://gist.github.com/gurunars/449edbccd0de1449b71524c89d61e1c5
"""
import re
import argparse