Python 3 code question

nachtmsk
nachtmsk used Ask the Experts™
on
Hi,
I got a Cozmo robot recently and I'm trying to write some code for it, it has a python API.

I am new to python and I'm first trying to understand the sample code they gave.
Here is one example:


-----------------
import cozmo
from cozmo.util import distance_mm, speed_mmps

def cozmo_program(robot: cozmo.robot.Robot):
  robot.drive_straight(distance_mm(150), speed_mmps(50)).wait_for_completed()

cozmo.run_program(cozmo_program)
------------------------
The line I am curious about is "cozmo_program(robot: cozmo.robot.Robot):"
So, it's a function call. But what is with the Colon ':' in the param?  " robot: cozmo.robot.Robot".  Does it mean that 'robot' is an instance of cozmo.robot.Robot?

In fact I'm also unclear what cozmo.robot.Robot means. Can someone break down that line and explain please?

Thanks!
Nacht
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
def function_name(attribute: attribute_type):
That is an annotation.

HTH,
Dan

Commented:
The answer is correct.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial