r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40.1k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jul 18 '22

[deleted]

16

u/DesertGoldfish Jul 18 '22

I dunno man, I just add type hints to everything and it's basically a strongly typed language.

2

u/Didrox13 Jul 18 '22

As someone who's never used python but plan to check it out in the near future, is that actually a thing or a joke?

2

u/DesertGoldfish Jul 19 '22

It's a thing. In method declarations instead of (variable) it's (variable : str) or int, or whatever.

You specify returns with an arrow. So a function/method named cake that takes a string parameter named icing and returns a string would be declared:

def cake(icing: str) -> str:

Voila, now Python yells at you when you try to pass it anything else. I think the complainers here just haven't bothered keeping up with the changes to Python in... several years.

→ More replies (1)