HP Caliper Advisor Rule Writer Guide
• For loop
for target in sequence:
true_statements
else:
false_statements
where the else clause and its associated statements are optional and are only
executed if the loop ends without executing a break statement. Note the use of the
colon (:) after each condition and note the indented statements.
• Pass, break, and continue statements
pass
break
continue
where pass is a do-nothing statement, break terminates a loop early, and
continue skips to the next loop iteration.
• Function definition
def function_name (parameter_list):
statements
where the default value for an optional parameter is given as parameter_name
= default_value. The return type (if any) of a function is not specified; it
depends on the return statement. Note the use of the colon (:) after each condition
and note the indented statements.
• Return statements
return the None value is returned
return expression expression can be a multi-valued sequence
where the default value for an optional parameter is given as parameter_name
= default_value. The return type (if any) of a function is not specified; it
depends on the return statement. Note the use of the colon (:) after each condition
and note the indented statements.
• Exception handling
try:
statements
except:
statements
else:
statements
where the except and else clauses and their associated statements are optional.
The except statements are executed if any exception is raised by the try
statements. The else statements are executed if no exception is raised. Note the
use of the colon (:) after each condition and note the indented statements.
This is the simplest form of exception handling and is generally used in rule
functions.
68 Python Scripting Language: Overview