
These kind of problems can easily be handled with numpy:
import numpy as np print(np.union1d(np.arange(3,15,2), np.arange(8,12,2))) [ 3 5 7 8 9 10 11 13]
Op 3/08/2022 om 21:23 schreef Random832:
On Mon, Aug 1, 2022, at 09:19, Paul Moore wrote:
There are a lot of complex cases you'd need to consider. What would the value of range(3, 15, 2) + range(8, 12, 2) be? It's not a range in the sense of being describable as (start, end, step). And simply saying "that's not allowed" wouldn't really work, as it would be far too hard to work with if operations could fail unexpectedly like this. In reality, this feels more like you're after set algebra, which Python already has.
Maybe it would make sense for the type of the result to devolve into a sorted set (do we have a sorted set type now?) if it's not representable as a range. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/PKGCHW... Code of Conduct: http://python.org/psf/codeofconduct/