Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
type of result of iter()
#11
snippsat Wrote:Could run it trough next(),and catch the in error in try:except.
The drawback is that next() consumes the first item of the iterator. So it won't work if you want to check if it is an iterator and then traverse the iterator.
Reply
#12
(Feb-07-2020, 08:16 AM)Gribouillis Wrote: The drawback is that next() consumes the first item of the iterator. So it won't work if you want to check if it is an iterator and then traverse the iterator.
Ahh of course that would be a drawback thanks for info.
Reply
#13
sometime LBYL gives you more detail about what is wrong. the could be of value in detailed error messages or when applying a correction such as substituting an empty list.

unless, of course, your can save what you got from next() when there is no exception.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Type hinting - return type based on parameter micseydel 2 2,469 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Unexpected expected type error result MartinMaker 1 2,043 Feb-16-2019, 05:02 PM
Last Post: micseydel
  python list iter issue anna 6 4,426 Apr-09-2018, 06:53 AM
Last Post: anna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020