no side effects
Michele Simionato
mis6+ at pitt.edu
Wed Jan 8 11:27:24 EST 2003
"Bo M. Maryniuck" wrote:
>
> On Wednesday 08 January 2003 15:10, Michele Simionato wrote:
> > I was surprised by the following code:
> > >>> for i in [1,2,3]:
> > ... print i,
> > ... i=3
> > I would have expected only 1 to be printed,
> Wrong.
>
> > but instead Python continues the loop
> Yes.
>
> > Maybe others will appreciate that.
> Probably you want this:
> >>> for i in [1, 2, 3]:
> ... print i
> ... if i == 1:break
> ...
> 1
>
> --
> Regards, Bogdan
>
> Professionalism has no place in art, and hacking is art. Software Engineering
> might be science; but that's not what I do. I'm a hacker, not an engineer.
> -- jwz
No, I *know* the break statement. It was just an example of the
wonders of Python.
Regards,
--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/
More information about the Python-list
mailing list