Oct-08-2016, 08:12 AM
So I created a python file called useful_turtle_functions and saved it to the same folder as the file I would like to import this into.
def drawLine(x1, y1, x2, y2): print('drawLine called {}, {}, {}, {}'.format(x1, y1, x2, y2)) def writeText(s, x, y): print('writeText called {}, {}, {}'.format(s, x, y)) def drawPoint(x, y): print('drawPoint called {}, {}'.format(x, y)) def drawCircle(x, y, radius): print('drawCircle called {}, {}, {}'.format(x, y, radius)) def drawRectangle(x, y, width, height): print('drawRectangle called {}, {}, {}, {}'.format(x, y, width, height))then I can do
import useful_turtle_functions useful_turtle_functions.drawLine('x1', 'y1', 'x2', 'y2') useful_turtle_functions.writeText('s', 'x', 'y') useful_turtle_functions.drawPoint('x', 'y') useful_turtle_functions.drawCircle('x', 'y', 'radius') useful_turtle_functions.drawRectangle('x', 'y', 'width', 'height')which gave
Output:drawLine called x1, y1, x2, y2
writeText called s, x, y
drawPoint called x, y
drawCircle called x, y, radius
drawRectangle called x, y, width, height