screen, its direction, and its color, among other things. When a
Turtle object is created, all the information is stored in the object.
This is called constructing an object and it happens when we
call the constructor. So, when we write the following line of code or
similar lines of code for other types of objects:
Except in a few special circumstances, a constructor is always called
by writing the name of the class then a left paren, then any arguments
to pass to the constructor, followed by a right paren. Calling a
constructor returns an instance of the class, called
an object. For a few of the built-in classes there is some
syntactic sugar available for creating objects. In Example 4.3,
the variables u and r are initialized to point to an
integer object and a string object, respectively. Syntactic
sugar makes constructing objects for some of the built-in classes
more convenient and it is necessary in some cases. Without some
syntactic sugar, how would you create an object containing the
t = turtle.Turtle()
Mutator methods, as the name suggests, change or mutate the state of
the object. Sec-tion 3.5 introduced the mutability of lists. Mutator
methods are called the same as accessor methods. Where an accessor
method usually gives you information back, a mutator method may require
you to provide some information to the object.
Example 4.5 Here are some calls to mutator methods.