Function in python file not running from sikuli

Asked by April L on 2018-05-15

I have written a sikuli script and then imported the python file. When I try to access a particular function (which is in the python file) from my sikuli script the required action is not performed. Sikuli is able to access the python file, if I run the sikuli script and there are any errors in the python file I can see them on sikuli logs. Just the function isn't running.
The files look similar to this

---Sikuli script---
import nameofpythonfile as lsyb
reload (lsyb)

     class firstclass(object):
         def __init__(self):
  "Path of file")
            #there are some other function in between

         def search(self,p)

---python file---
def func(self,p):

#some other functions
if __name__=="__main__":

The above file prints Hello when I run it directly but not when I run it from sikuli.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Best RaiMan (raimund-hocke) said : #1

I am not sure, what you are trying to achieve, but this works having main.sikuli and in the same folder:

# main.sikuli
import sub as lsyb
reload (lsyb)

class firstclass(object):
  def __init__(self): #.nameofpythonfile("Path of file")

  def search(self, p):

cls = firstclass()

def func(p):
  print("Hello" + str(p))

--- I do not understand, what this should do:"Path of file")

--- a method def only needs self as first parameter if defined in a class

--- a class itself does nothing (just a dfinition) - to use it, it must be instantiated

April L (april96) said : #2

Thanks RaiMan, that solved my question.