how to pass an argument to an imported function in a sikuli script

Asked by Marc Summers

I have a main sikuli test .py script, and I have several import functions
in it. But one of them I would like to be able to pass in an argument
to the import function like

import functionname(49)

I have tried several different methods but
can not get it to work.

Do you know the magic algorithm ?

Thanks for your help.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

Hmmm... To my best knowledge import is not a function but a statement, and you import not function, but a module or submodule.

You need to define a function within module, like

mod123.py
======
def function123(a):
    # do something with a
======

and then call the function in the module where you import

======
import mod123
function123(49)
======

Revision history for this message
RaiMan (raimund-hocke) said :
#2

@Roman

usage either:

import mod123
mod123.function123(49)

or

from mod123 import *
function123(49)

for the second case, you need a naming convention, to avoid name clashes

Can you help with this problem?

Provide an answer of your own, or ask Marc Summers for more information if necessary.

To post a message you must log in.