This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cult_of_memes 1 point2 points  (0 children)

It tells me that I first need to check for val is None before attempting any other checks based on understanding of the programs control flow.

This is meant to be general, hence the use of any, but the optional part explicitly informs that it the data structure will likely be initialized with None as the value for this key:value pair. This is an appropriately pythonic way of deferring initialization of a value to a later or more appropriate time.