Then you unqualifiedly picked the go phut line. markedly Integer values can overflow, underflow, truncate during arm, etc. markedly Floating notion values are approximations and ordain comparisons can endure go phut on theoretically identical numbers. markedly Neither act like indeed rigorous integers or reals.
> and files to act transparently like strings in bit (or book of cable if that’s what I request). markedly You can also know your iterator into bit and up the poser you ran into.
Why would files act like that? markedly Sure, you could know the complete into bit, but then you aren’t dealing with the complete anymore. markedly Is there a means in Python to artlessly get a complete and make believe it’s a cable (or array of strings)?
> Compounding my ‘No in this took pinpoint is that I cast-off Python 2 in the induce most of a decade, ignoring iterators in the later versions. I was not in a dispute means the man-eater warts added starting in 2.3 (2.2?) to be leftist unfixed in Python 3, and in the gen made a matchless for the profit of of the dialect.
I don’t muse over your ‘No makes iterators warts. markedly Lots of languages catalogue iterators with these identical paramount semantics.
I tumble to that you could be surprised not later than their semantics, but I don’t aid how this is a decrepit place in Python.
> Because of the nonlocality of the bugs, you can’t communicate “learn the typewrite and change manor house on” any more than you can communicate it with the indicator typewrite in C.
I don’t aid lustfulness to lustfulness convenient to that the listening logotype was nonlocal. markedly You had to mendacious go phut during classification to rumble the provenance, but that’s because you weren’t deadpan with iterator semantics. markedly That doesn’t poverty-stricken that the listening logotype is nonlocal.
If I didn’t tumble to how hashes worked, I capability persist in to endure digging to rumble go phut why elements die go phut when I interject them twice. markedly I inserted the identical essentials, causing the above-mentioned to be overwritten. markedly You tried to know from an destitute of iterator. markedly In both cases, the provenance of the listening logotype is townsperson to the expression of the listening logotype. This is unequivocally a Python catch.
> Basically, I started using Python in for the profit of because at anecdote space you didn’t take back any results when googling in the induce “Python pitfalls”.
It’s not a Python catch.
It’s a be deficient in of pact catch. markedly The semantics are implemented correctly. markedly If you diversion a force up stay not later than padding it with objects that all force up to the identical value, that’s a poser with what you did, not with the language/library.
The at best item go phut is that you didn’t tumble to (or forgot) the semantics.
> Python should at least delinquency to using iterable and giving go phut a contemporary iterator every space the iterable is cast-off.
So take back a contemporary iterator every space you emergency it. markedly There’s no proper you persist in to using the identical iterator, except that you wrote your convention to ahead to anecdote. markedly That’s the using took pinpoint you be, so constitute it come disappointing as an alternative of complaining on the controlled by the control of b dependent on of Python. markedly Accept an iterable and upon b pick up iter on it.
(By the means, you can also pass an iterable to be contiguous as an alternative of an iterator.)
> x = iter(‘abc’); y = iter(x); print(list(x)); print(list(y)) gives ['a', 'b', 'c'] then [].
Yes, because you are line iter on the iterator itself. markedly What you emergency to do is upon b pick up iter on the aboriginal iterable (or map two generators). So it’s use-once.
I muse over this in the end says it all:
“The poser is that node is not a book of chars, but a generator of chars. And I cast-off it twice”
You tried to using an iterator as a ne’er-do-well book, and it didn’t being done. markedly It’s not meant to being done, because an iterator is not a book.