scripts 1:
import turtle
turtle.Screen().bgcolor(‘red’)
scripts 2:
import turtle
turtle.bgcolor(‘red’)
For both scripts get the same result. So what is the difference between turtle.Screen().bgcolor() and turtle.bgcolor()? which is the proper way to use?
Thanks.
adorilson
(Adorilson Bezerra)
March 16, 2025, 7:16pm
2
There is no practical difference.
One uses an oriented-object approach, and the other uses a procedural approach, both accessing the Screen singleton object.
The same way you do
>>> import turtle
>>> turtle.forward(100)
in a procedural approach.
Or
>>> import turtle
>>> t = turtle.getturtle()
>>> t.forward(100)
in an oriented-object approach.