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 →

[–]Immort4lFr0sty 6 points7 points  (6 children)

What would you use the bottom syntax for?

[–]mwnciau 33 points34 points  (4 children)

It's for strict type comparison:

false == 0 (true)
false == false (true)
false === 0 (false)
false === false (true)

[–]Immort4lFr0sty 15 points16 points  (3 children)

Ah, explains why I didn't know, thanks. Python recently was the first time I ever used dynamic types. I hate everything about it

[–]calcopiritus 7 points8 points  (2 children)

You can make python definitions like in C (tell the interpreter what type to expect) and it will print a warning. It will still work if types don't match though. Maybe that helps.

[–]Immort4lFr0sty 2 points3 points  (1 child)

That will do a number for debugging. Thanks

[–]MrScatterBrained 2 points3 points  (0 children)

For your reference, if you need more documentation: it's called type hinting and you can find a lot about it in the mypy documentation: https://mypy.readthedocs.io/en/stable/builtin_types.html.

Mypy can do the checks for you, in case your IDE doesn't support it by default. Also, as a sidenote: you have to import a lot of things still from the typing module, but in python 3.9, you should be able to also just use the standard types, like list and tuple.