Python 3, an Illustrated Tour Transcripts
Chapter: Type Annotations
Lecture: Variable annotations

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So we saw the new style, 526 style of annotating variables.
0:05 Pep 484 had another style for annotating variables
0:09 allowed us to do in a comment.
0:11 So if you put the comment with type colon,
0:14 and then the expression following that, in this case str,
0:16 we could use this older style pep 484.
0:19 Python 3.6 supports this newer style,
0:21 and so we can just put the colon and the annotation right after that.
0:25 One thing to note when we create these variable annotations is that
0:28 there is a global variable called __annotations__
0:32 that will be created and it will be updated with the name and the types in there.
0:36 Note that, again, this middle variable here does not have a value,
0:40 it's just an annotation for a variable.
0:43 And so if I try and reference that here,
0:45 I will get a name error that middle is not defined,
0:47 but note that middle is in my annotation.
0:50 So when I later assign middle, it should correspond with that type.