r/Python • • Jan 05 '18

Really??

Post image
2.0k Upvotes

317 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Jan 05 '18

like a compiler does.

Like MyPy does. You want strict typing, you can do it fine. It's done better than it is for most languages (Looking at you C#. Still waiting for nullability for everything) It's not enforced at runtime (even though runtime type checking exists, it shouldn't be needed if it passes a static type checker), it just shows errors when you fuck up.

1

u/traway5678 Jan 06 '18

What can't you null in C#?

1

u/chusk3 Jan 06 '18

reference types (ie classes) can be null, but currently can't be typed as possibly null. The benefit would come from saying that a certain thing can never be null in the type system, which you can't do in C# now

1

u/traway5678 Jan 06 '18 edited Jan 06 '18

Everything can be null, with nullable.

You can make non-nullable types, aka values, with structs as well.

The benefit would come from saying that a certain thing can never be null in the type system, which you can't do in C# now

Oh that's not what he said tho.

-1

u/midbody Jan 05 '18

It really doesn't.

4

u/[deleted] Jan 05 '18

So where does MyPy not work as well?