MCPcopy Index your code
hub / github.com/python/cpython / clone

Method clone

Lib/turtle.py:2845–2883  ·  view source on GitHub ↗

Create and return a clone of the turtle. No argument. Create and return a clone of the turtle with same position, heading and turtle properties. Example (for a Turtle instance named mick): mick = Turtle() joe = mick.clone()

(self)

Source from the content-addressed store, hash-verified

2843 self.begin_fill()
2844
2845 def clone(self):
2846 """Create and return a clone of the turtle.
2847
2848 No argument.
2849
2850 Create and return a clone of the turtle with same position, heading
2851 and turtle properties.
2852
2853 Example (for a Turtle instance named mick):
2854 mick = Turtle()
2855 joe = mick.clone()
2856 """
2857 screen = self.screen
2858 self._newLine(self._drawing)
2859
2860 turtle = self.turtle
2861 self.screen = None
2862 self.turtle = None # too make self deepcopy-able
2863
2864 q = deepcopy(self)
2865
2866 self.screen = screen
2867 self.turtle = turtle
2868
2869 q.screen = screen
2870 q.turtle = _TurtleImage(screen, self.turtle.shapeIndex)
2871
2872 screen._turtles.append(q)
2873 ttype = screen._shapes[self.turtle.shapeIndex]._type
2874 if ttype == "polygon":
2875 q.turtle._item = screen._createpoly()
2876 elif ttype == "image":
2877 q.turtle._item = screen._createimage(screen._shapes["blank"]._data)
2878 elif ttype == "compound":
2879 q.turtle._item = [screen._createpoly() for item in
2880 screen._shapes[self.turtle.shapeIndex]._data]
2881 q.currentLineItem = screen._createline()
2882 q._update()
2883 return q
2884
2885 def shape(self, name=None):
2886 """Set turtle shape to shape with given name / return current shapename.

Callers 1

send_messageMethod · 0.45

Calls 8

_newLineMethod · 0.95
deepcopyFunction · 0.90
_TurtleImageClass · 0.85
_createpolyMethod · 0.80
_createimageMethod · 0.80
_createlineMethod · 0.80
appendMethod · 0.45
_updateMethod · 0.45

Tested by

no test coverage detected