Dot operator and importing commands Pro Preview

Have you noticed how the "run()" is written after the "Motor()" command and they are separated by a dot? This dot separation is called a "Dot" operator.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1528
  • 28 Jan 2020

The dot tells the robot that the "run()" command is a property of the "Motor()" object. "Motor()" holds information regarding which motor must be activated by the "run()" command and without this information, the "run()" command cannot be executed.

In order to use these commands, we need to add the following 2 lines of code at the beginning of our program:

from pybricks.ev3devices import (Motor)

from pybricks.parameters import (Port)

With them, we import the "Motor" and "Port" ("Port" allows us to enter which port our motor is at in the "Motor()" command). Notice that the "run()" command is not imported, because it comes imported with the "Motor" object as its property.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Python with LEGO Mindstorms EV3 - Level 1
  • 43
  • 22:57
  • 30
Image for Lesson 2 - Robotic arm
  • 9
  • 5
  • 9
  • 3d_rotation 1
Image for Python with LEGO Mindstorms EV3 - Level 1
  • 43
  • 22:57
  • 30
Image for Additional Tasks
  • 3
  • 0
  • 8
  • 3d_rotation 0