Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
generators with errors
#1
normally a generator initially returns a reference to an instance of that generator which is holding specific parameters and/or data it needs to do its particular thing. but what if the given parameters are out of bounds for what makes sense to that generator. is raising an exception the right way to do this (as opposed to only yielding None, for example)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
(Jun-15-2022, 10:47 PM)Skaperen Wrote: is raising an exception the right way to do this
Raising an exception is always the right way. It gives the driving code the opportunity to catch the exception and take appropriate action.
Skaperen likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  generators as filters Skaperen 0 2,186 Apr-23-2018, 03:30 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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