The If Statement

<< Click to Display Table of Contents >>

Navigation:  AutoTRAX PCB Design Express (DEX) > Appendix > Scripting > Python > Control Statement >

The If Statement

Conditional Execution

The if, else, and elif statements control conditional code execution.The general format of a conditional statement is as follows:


if design.IsProject:

 print 'The design is a project'

elif design.IsPart:

 print 'The design is a part

elif design.IsArt:

 print 'The design is an artwork file'


 print 'The design type is unknown'


There can be zero or more elif parts, and the else part is optional. The keyword ‘elif‘ is short for ‘else if’, and is useful to avoid excessive indentation.

An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.