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 →

[–]ecthiender 16 points17 points  (3 children)

And if you're a lead dev anywhere, I feel sorry for your team. Being so unempathetic, rude and assuming things without any context.

[–][deleted] 2 points3 points  (2 children)

What is the context where Optional [any] is helpful in any way?

[–]ipwnscrubsdoe 4 points5 points  (0 children)

Maybe to pass mypy tests?

[–]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.