← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #177234]: Backspace x 10

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
ok, this is one of the most frustrating things for newcomers regarding
the Python language :-(

aaaarrrrggghhh !!!!! indentation error ***???***

indentation is the tool in Python to build blocks of statements, that belong together (e.g. the body of a function or a loop). dedentation marks the next statement, that does not belong to the block any more, but it has to match any indentation of an outer block, that was used before.
Sounds complicated, but is not. In other languages you usually use some bracketing instead.

So lets try to learn something from the error message:

-- where did it happen?

11, 1, ' myMulti(30)) # 30 backspaces\n'

it is line 11 character position 1

-- what is wrong?
IndentationError: ('unindent does not match any outer indentation level'

It is not possible, to evaluate, to which block this statement belongs,
since it starts with a blank (no other statement before starts with an
indent of one blank!)

so get rid of the blank.

all statements on block level 0 (the script level) have to be left
justified!

-- TIP: only use tab/shift-tab to indent dedent. A tab is converted to 4
spaces automatically and shift-tab deletes 4 spaces from the beginning
of the line.

-- BTW:
# usage:
myMulti(30)) # 30 backspaces
myMulti(10, Key.DOWN) # 10 down's

only wanted to show the 2 different usage possibilities.

*** So your case:

# functions should be placed at the beginning of the script
def myMulti(n, k = Key.BACKSPACE):
      for i in range(n):
          type(k)

click(Pattern("Updatefuldcr.png").targetOffset(79,24))
myMulti(30)) # 30 backspaces

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