[Tutor] generators?

dman dsh8290@rit.edu
Fri, 30 Nov 2001 10:17:38 -0500


On Thu, Nov 29, 2001 at 10:10:50PM -0800, Kirby Urner wrote:
| 
| >
| >  >>> for i in range(0,1,.1): print i,
| >
| >  0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
| 
| OK, I get it now.
| 
| yield, like print, is not returning the full floating

Actually, yield returns the object you have it yielding, whatever that
is.  It is your "print" (that prints the yielded object) that is
causing the rounding to occur.

| start didn't quite reach 1, and so actually yields 1.0
| (in the original version) before quitting.
| 
| Moral:  floating point can be tricky!  Take care.

Right.

-D

-- 

the nice thing about windoze is - it does not just crash,
it displays a dialog box and lets you press 'ok' first.