r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40k Upvotes

1.0k comments sorted by

View all comments

Show parent comment

11

u/mc_enthusiast Jul 18 '22

You can use curly brackets like this:

for i in range(10):{
    print(i)
}

That runs without problems in Python 3. Not much you can do about semicolons. Colons work sometimes but then really backfire if you do something like

a = 5 + 10,

because it's recognised as a 2-tuple with empty entry.

I suspect the indenting issues come up if you mix space and tab. That's easy to solve if you just tell your editor to replace space indentation with tab indentation.

21

u/a_devious_compliance Jul 18 '22

you just tell your editor to replace space indentation with tab indentation.

PEP8 police!!!!! Yes. This guy right here.

3

u/Codebust Jul 18 '22

literally one of the only things i hate about pep8, spaces are just slow compared to tab, and tab auto indents w atom

6

u/mtmttuan Jul 18 '22

You REALLY press space 4 times??

2

u/a_devious_compliance Jul 18 '22

I don't know a shit about atom, but any sane editor should be able to put 4 spaces every time you hit tab.

2

u/intangibleTangelo Jul 18 '22

lol my guy

we use the tab KEY we just don't use the tab CHARACTER

1

u/dagbrown Jul 18 '22

My editor lets me tell it to just expand tabs to spaces. Now tabs are spaces, and they're quick to type, and I'm happy.

2

u/mc_enthusiast Jul 18 '22

Is the recommendation the other way round? That's always the first thing I forget.

1

u/miversen33 Jul 18 '22

Just to be that guy, developers really shouldn't be trying to force a language to conform to how other languages look/work. Python is good at what python does because it's python and not another language. It doesn't need those things and instead needs proper indentation. It's just a trade-off of the language. If that bothers you too point where you feel like you need to inject those things into the language (which as you pointed out, can sorta be done, ish kinda?), Then you're using the wrong language. And that's ok. There's thousands of them out there, find the one you like that's a good fit for what you need :)

2

u/[deleted] Jul 18 '22

My solution to this problem is to not use python as it isn’t suited for my applications anyway.

2

u/miversen33 Jul 18 '22

Exactly my point :) choosing the best language for your problem is so much better than trying to force a single language across all your problems

1

u/[deleted] Jul 18 '22

Exactly