Python script - cannot call def from another def

Hopefully an easy question to answer, I cannot seem to call a def from another def (possibly due to the way hass wraps script files?)

Example:

global gLogger
gLogger = logger

def one():
  gLogger.info("one")
  two()
  
def two():
  gLogger.info("two")

one()

Executing this python script gives me:

Error executing script: name 'two' is not defined

Does hass wrap these scripts in a way where I need to call a parent method to access the other defs? Could someone demonstrate the proper way to call two from the one definition in this scenario?

Apparently wrapping all the defs in an overall def will solve the problem. Inconvenient, but it works.

global gLogger
gLogger = logger

def main():

  def one():
    gLogger.info("one")
    two()

  def two():
    gLogger.info("two")

  one()

main()

I’ll use this as a workaround, unless anyone has a better idea.