Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Python script - cannot call def from another def

$
0
0

@RandomHassUser wrote:

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?

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>