Monday 26 February 2018In the #python IRC channel today,
someone asked:Does anyone know of any libraries that could convert ‘1-5,7,9,10-13’
to [1,2,3,4,5,7,9,10,11,12,13] ?This seemed like an interesting challenge, and people started offering code.
This was mine. It’s ungainly and surprising, and I wouldn’t want to keep it,
so I call it a gargoyle:[ i for p in s.split(',') for a, _, b in [p.partition('-')] for i in range(int(a), int(b or a)+1)
https://codango.com/ned-batchelder-a-python-gargoyle/
I am happy to share this resource that we found. The content displayed on this page is property of its original author or their organization.
No comments:
Post a Comment