← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #224366]: Reuse of code through import

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
when using <import xyz>, you have to qualify the contained def's with the module name:
xyz.fct1()

If you have long module names you can assign shortcuts:
import this_is_a_very_long_module_name as sub
sub.fct1()

and you can use
from xyz import *

which loads all global names defined in xyz to your current namespace, so you can now say:
fct1()

This last option is the most convenient if you have some naming convention (like you seem to plan).
But same names defined later in your script being the same as in the module will overwrite without notice (hard to find bugs ;-)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.