Python#

The VEX CTE Python API Reference explains what each command, method, and function does, what inputs it uses, what it returns, and how it can be used in a project.

Use this reference when you want to understand a command before adding it to a project, check what values it accepts or returns, or compare related commands in a category.

Python commands are used in VEXcode Python projects. Blocks projects use the Blocks API section instead.

How to Read a Method Entry#

Most Python entries include the following parts:

  • Command name - The official name of the command, method, or function.

  • Description - Explains what the command does and when it is useful.

  • Usage - Shows the syntax used to write the command in code.

  • Parameters - Lists the inputs the command accepts and explains what each one does.

  • Return value - Explains what the command reports back, if it returns a value.

  • Example code - Shows one way the command can be used in a project.

Common Python API Elements#

Element

What it means

Method

A command called on an object such as arm.move_inc(…).

Function

A command called directly, such as wait(…) or print(…).

Parameter

A value passed into a method or function to control what it does.

Optional parameter

A parameter that can be left out so the default behavior is used.

Return value

A value a command reports back, such as a number, text, or Boolean.

Basic Python Vocabulary#

Term

What it means

Variable

A name that stores a value, such as x_target = 120.

String

Text inside quotes, such as “Hello”.

Integer

A positive or negative number, such as 90.

Float

A number with a decimal, such as 25.5.

Boolean

A value that is either True or False.

Argument

A value passed into a method or function call, such as 100 in arm.move_inc(0, 100, 0).

Example Method Entry#

move_inc#

move_inc moves the 6-Axis Arm by a specified distance along the x, y, and z axes.

This method will return a Boolean indicating whether the 6-Axis Arm has reached the requested position:

  • True - The 6-Axis Arm has reached the requested position.

  • False - The 6-Axis Arm cannot reach the requested position.

Usage:
arm.move_inc(x, y, z, wait)

Parameter

Description

x

The distance to move along the x-axis in millimeters.

y

The distance to move along the y-axis in millimeters.

z

The distance to move along the z-axis in millimeters.

wait

Optional.

  • wait=True (default) - The project waits until move_inc is complete before executing the next line of code.
  • wait=False - The project starts the action and moves on to the next line of code right away, without waiting for move_inc to finish.

# Move the Arm +100 millimeters on the y-axis
arm.move_inc(0, 100, 0)