Python Forum
incremental testing in all()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
incremental testing in all()
#10
Here the proof without have to read C.

deadeye@nexus ~ $ ipython                                                                                                       
Python 3.7.4 (default, Jul 10 2019, 23:32:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.7.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: class Iterator: 
   ...:     def __init__(self): 
   ...:         self.last = None 
   ...:          
   ...:     def __iter__(self): 
   ...:         for i in range(10): 
   ...:             print(i) 
   ...:             if i < 5: 
   ...:                 yield True 
   ...:             else: 
   ...:                 yield False 
   ...:                                                                                                                         

In [2]: all(Iterator())                                                                                                         
0
1
2
3
4
5
Out[2]: False
The loop is stopped, when False is yielded.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
incremental testing in all() - by Skaperen - Aug-15-2019, 11:47 PM
RE: incremental testing in all() - by Skaperen - Aug-17-2019, 04:15 AM
RE: incremental testing in all() - by buran - Aug-17-2019, 06:01 AM
RE: incremental testing in all() - by Skaperen - Aug-18-2019, 07:10 PM
RE: incremental testing in all() - by perfringo - Aug-17-2019, 07:12 AM
RE: incremental testing in all() - by Gribouillis - Aug-17-2019, 07:36 AM
RE: incremental testing in all() - by buran - Aug-18-2019, 07:25 PM
RE: incremental testing in all() - by Skaperen - Aug-18-2019, 07:59 PM
RE: incremental testing in all() - by DeaD_EyE - Aug-18-2019, 11:36 PM
RE: incremental testing in all() - by Skaperen - Aug-19-2019, 06:18 AM

Forum Jump:

User Panel Messages

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