question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider deprecating iter

See original GitHub issue

I think iter should probably not be part of the library’s public API surface.

Strings and arrays are already iterables. A deprecation notice could warn users when an object is passed to iter, informing them that they should use entries instead.

Internally a function called iter could continue to be used with the same basic responsibility of making an iterator out of an iterable.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sithmelcommented, Jul 21, 2018

I was already happy removing “entries” from iter. That was super confusing: “What if I want the entries of an object but this is already iterable ?”

About the other changes, I had to review carefully the specs (and your comments @conartist6) to form myself an opinion. What is important IMO was to be able to work with any object you could pass to “for … of” and to return an object you can pass to the “for…of”. In the specs it states that “for …of” works with object implementing the iterable protocol.

This is implemented by generator objects built-in objects like arrays, strings, etc. , and custom object with @@iterator. So what is left out?

  • random objects implementing “next”, but they don’t work with the for … of loop already

So I am positive with these changes and the PR.

0reactions
sithmelcommented, Jul 21, 2018

Previous implementation was based on a few misconceptions of its author: myself 🤣

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reasoning for stream::iter deprecation? · Issue #576 - GitHub
This is interesting, I need to think about some of my impls that currently expect errors from the stream. Such as timeouts. Without...
Read more >
Deprecate "old-style iteration protocol"? - Ideas
My proposal is to deprecate this fallback mechanism, emit a DeprecationWarning at first and eventually raise a TypeError unless __iter__ is ...
Read more >
std::iterator is deprecated: Why, What It Was, and What to Use ...
What exactly has been deprecated, and what is the consequence on our code right now? This is what we discuss here.
Read more >
How to solve: WARNING : deprecated key derivation used ...
I am using OpenSSL version 1.1.1b (26 Feb 2019) to encrypt/decrypt files. Everything is working fine but I am getting a Warning I...
Read more >
Built in iter() function and for statement - python - Stack Overflow
We exit from loop once IndexError raises. To have the backward compatibility getitem method is still not deprecated (Till Python version 3.8.5).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found