Skip to content

Instantly share code, notes, and snippets.

@richmondwang
Last active August 16, 2016 14:31
Show Gist options
  • Save richmondwang/be39ddb6ec636ed96aff0e0e0bbcde60 to your computer and use it in GitHub Desktop.
Save richmondwang/be39ddb6ec636ed96aff0e0e0bbcde60 to your computer and use it in GitHub Desktop.
Coerces string into separate string tags
class Tags(object):
"""Converts string to tags, a list of string that was separated by comma
"""
def __call__(self, v):
if not isinstance(v, basestring) or v is None:
raise Exception()
tags = map(lambda x: x.strip(), list(v.split(',')))
tags = filter(lambda x: x != '', tags)
return tags
def __repr__(self):
return 'Tags()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment