Defnition calling another Definition already declared.

Asked by Leonardo Castro on 2020-02-20

Hello.

I'm tryng to call one definition already defined, inside another definition.

CODE:

def teste1(event):
     popup("teste 1")

def teste2(event):
     popup("teste 2")

def teste3(event):
     popup("teste 3")

def all(event):
    teste1()
    teste2()
    teste3()

all()

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Leonardo Castro
Solved:
2020-02-20
Last query:
2020-02-20
Last reply:
2020-02-20
RaiMan (raimund-hocke) said : #1

if a def() is defined with a positional parameter, it MUST be given when called.

This is a variant using keyword arguments:

def teste1(event = None):
  if not event:
     popup("teste 1")

def teste2(event = None):
  if not event:
     popup("teste 2")

def teste3(event = None):
  if not event:
     popup("teste 3")

def all(event = None):
  if not event:
    teste1()
    teste2()
    teste3()

all()

Leonardo Castro (leokastro) said : #2

Thank you Raiman!