?
Solved

Python 3 code question

Posted on 2017-01-05
2
Medium Priority
?
57 Views
Last Modified: 2017-01-24
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
0
Comment
Question by:nachtmsk
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points (awarded by participants)
ID: 41949310
def function_name(attribute: attribute_type):
That is an annotation.

HTH,
Dan
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 41976669
The answer is correct.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question