← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #651217]: How to call a function from other module

 

Question #651217 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/651217

    Status: Open => Answered

RaiMan proposed the following answer:
I always recommend, to strictly differentiate between library scripts
(no executable code (indent level 0)) and execution scripts.

Library scripts contain classes and functions, that are used elsewhere
more than once.

An execution script represents a workflow, where one or more
classes/functions are used from imported library scripts.

As said - my recommendation based on experience.

But if you  really want to: level 0 code in library scripts should be
guarded with an if-statement, that only gets true if the library script
is run as main script.

The most often used snippet for this case is
if __name__ == "__main__":
    # here your code, that only runs, if the module is a main script (not imported)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.