Whenever you extend the definition of an operation (`__iter__` in this case) to 
more existing objects, you lose a little bit of the ability to catch errors 
early. Consider the function:

    def traverse(something):
        for x in something:
            # do stuff
            ...

If you accidentally call `traverse(42)`, then right now, you catch it 
immediately with a TypeError on the `for x in something:` line. Under your 
proposal, you might just get a strange answer and not realize anything is wrong.

Besides, we already have ways to write "repeat 1 ten times", using 
`itertools.repeat(1, times=10)`. Or if you just need any iterable with ten 
items, you can use range(10). I think keeping numbers non-iterable is nice 
based on a couple of the lines PEP 20: `Explicit is better than implicit`, and 
`There should be one-- and preferably only one --obvious way to do it.`
_______________________________________________
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/ANFR3IQW5TJHV4JRZT5UI7VEMFL7BKX2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to