On 8/08/20 3:24 am, Paul Moore wrote:
def is_valid_specifier(s):
     try:
         packaging.specifiers.SpecifierSet(s)
         return True
     except packahing.specifiers.InvalidSpecifier:
         return False

This doesn't quite follow the pattern, because it doesn't return
the result of the function. To fit it into an except expression
you would need to write something more convoluted, such as

   (SpecifierSet(s), True)[1] except InvalidSpecifier: False

There might be a less clunky way to write that, but I can't
think of one right now.

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GFFGND5J5Q6S76PYZT333WFBO4HGT4ES/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to