title: Python Turtle: I want to make a function that executes another function depending on what the previously executed function was
body: <p>I'm drawing my name using turtles and I have a bunch of different functions for each of the letters</p>
  
  <p>like so (for letter r)</p>
  
  <pre><code>def letter_r(t):
  
      def letter_r_top(t):
          turtle.lt(90)
          turtle.fd(150)
          turtle.rt(90)
          turtle.circle(-37.5,180)
          turtle.lt(130)
  
      def letter_r_leg(t):
          csquare = ((75**2) + (37.5**2)) 
          sidec = math.sqrt(csquare)
          turtle.fd(sidec)
  
      letter_r_top(rob)
      letter_r_leg(rob)
  </code></pre>
  
  <p>After each letter, i need to move the turtle into the right place to setup for the next letter.  Because each of the letters are different sizes I need to make custom movements depending on what the previous letter is but I dont want to make separate functions for each of those movements.</p>
  
  <p>At the end of my code I have the list of functions to be called in the correct order to spell my name</p>
  
  <pre><code> letter_t(rob)
   letter_setup(rob)
   letter_r(rob)
   letter_setup(rob)
   .....
  </code></pre>
  
  <p>Is there a way that I can do something like this so that I will only need 1 setup function.(Not real code, just a conceptualization of what I'm thinking</p>
  
  <pre><code>def letter_setup(t):
      if previously executed function A 
          turtle.fd(75)
      if previously executed function B 
          turtle.fd(75)
          turtle.lt(90)
      if previously executed function C
          turtle.fd(75)
          turtle.lt(90)   
  </code></pre>