Eli Bendersky added the comment: On Sun, Sep 22, 2013 at 9:04 PM, Ethan Furman <rep...@bugs.python.org>wrote:
> > Ethan Furman added the comment: > > Yup, just trying to add some explanation on how it currently works. > > Drekin, I'm sure you've already figured this out, but for those who may > read this in the future: what you need is a helper function: > > def OptionalEnum(value): > "could also be OptionalEnum(enum, value)" > try: > return SomeEnum(value) # or return enum(value) > except ValueError: > return value > Hmm, looks suspiciously similar to _inienum_converter from socket.py ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19040> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com