Taken from WinterSim 2018 DEVS tutorial for a general overview of PythonPDEVS:
http://msdl.cs.mcgill.ca/projects/DEVS/PythonPDEVS/Tutorial/18.WinterSim.DEVSTutorial.pdf

The main loop op PythonPDEVS is theoretically defined with the following Operational Sementics:

time = 0
current_state = initial_state
last_time = -initial_elapsed
while not termination_condition():
    next_time = last_time + ta(current_state)
    if time_next_ev <= next_time:
        e = time_next_ev – last_time
        time = time_next_ev
        current_state = 𝛿_𝑒𝑥𝑡((current_state, e), next_ev)
    else:
        time = next_time
        output(𝜆(current_state))
        current_state = 𝛿_𝑖𝑛𝑡(current_state)
    last_time = time

Or in human speak:
    The external transition function is only called on an item input.
    The output function is called BEFORE the internal transition function.
