Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python Type Hinting!
You have completed Python Type Hinting!
Preview
The simplest type hinting is by using the built-in types. Let's see how to hint functions that are only concerned with the built-in types.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
except where I do variable annotations.
0:00
That's a Python 3.6-only feature, but
that, along with some other additions and
0:01
fixes, are a great reason
to consider updating.
0:05
So let's start with a simple calculator.
0:08
So we've got add, subtract,
multiply, divide.
0:10
And we're just kind of being naive, and
0:13
we're just assuming whatever gets
passed in can be added together.
0:15
Like I said,
this is a really simple example.
0:18
So right now the calculator will work
with many different Python types, right?
0:21
We could add two strings together or
multiply a string by an integer.
0:24
We could, of course, do all of these
operations with ints, floats, or
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up