Issue 1519566: turtle.py: correcting begin_fill (original) (raw)
In the current version of turtle.py begin_fill behaves exactly like fill(True). That means, that a call begin_fill() does a filling if another call begin_fill() has been issued before. To see this, try:
from turtle import * begin_fill() forward(100) left(50) forward(100) begin_fill()
Imho this is not very plausible. (Of course, calling begin_fill twice is also not very plausible, but may be done by beginners inadvertedly). I encountered this problem first in a course for teachers I gave today.
I propose that begin_fill should behave differently, namely start a new filling (as it's stated in the docs, which are - as you see- in fact for this function incomplete) and discard the butlast call to begin_fill. If one really needed the current functionality , one could resort to fill().
I discussed this with Vern Ceder at edupython list and he replied:
Personally, my vote would be to fix it as you suggest and submit the patch as soon as possible - it may just be possible for it to make it into the 2.5 release.
Please note, that begin_fill was just added to 2.5, so this slight change of functionality shouldn't create problems.
So I submit a patch, which does this. This patch also eliminates the attribute _tofill, which is not needed anymore. (I think it was needed in the old circle method). Moreover the forward(0) call at the end of the definition of the fill method is eliminated as it does nothing but unnecessarily duplicate a pair of coordinates to the _path list
The patch contains also a short addition to the demo() function, which shows that now concave forms can be filled.
Subsequently I'll add a short patch to the turtle.py Documentation