sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05787
Re: [Question #156506]: Getting Indentation error --- only use tab to indent and shift-tab to dedent
Question #156506 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/156506
RaiMan posted a new comment:
@ gregory
Uuups, I do not think, that indentation/dedentation is something so
mystic, that it could make someone nuts ;-)
--- only some rules
- first line in a script/module is indent 0 and has to be left justified
- for, while, if, else, elif, try, except, def, class and few others need a block of statements to follow containing at least one statement
- the first statement of a block has to be indented by one level
- a block of statements are the consecutive statements with the same indentation
- an indentation can be any combination of spaces and tabs
- same indentation means: same sequence of blanks and/or tabs
- blocks can be nested
- a block ends before the statement with a lower indentation level and it's indentation must match exactly (same indentation) an indentation towards the beginning of the script
- lines containing comments are ignored
- lines containing only whitespace characters are ignored
Not so abstruse I think and with the recommendation "only use tab/shift-
tab" it is really manageable.
'C:\\Users\\gregory\\AppData\\Local\\Temp\\sikuli-
tmp4625430662202172482.py', 97, 4, ' def open_smc(self): \n'))
the message tells you, that there is a problem with line 97 at position
4 with def ....
I guess, that the def must be on position 0 (indent level 0, left most).
"unindent does not match any outer indentation level" means, that there
is no statement before (e.g. another def or class), that needs this def
to be indented on level. Usually a def has to be left justified (e.g. in
imported modules).
exception: def's in def and def's in a class
def with_internal_def():
def internal_def():
pass
class MyClass():
def __init__(self):
pass
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.