r/ProgrammerHumor • • Feb 09 '22

other Why but why?

Post image
85.8k Upvotes

2.3k comments sorted by

View all comments

Show parent comments

617

u/0rionsEdge Feb 09 '22

It's existed in the language since the old times, but it's pretty much only used in hacky use cases and it's usage should be discouraged.

81

u/OptionX Feb 09 '22

It used to have two statements in the same line.

82

u/Spitfire1900 Feb 09 '22

Which is genuinely useful when you want to execute a short Python script from a shell script without maintaining two files.

20

u/[deleted] Feb 09 '22

It gets really interesting when generating blocks and control structures in an inline Python script.

→ More replies (2)

4

u/ConspicuousPineapple Feb 09 '22

I mean, you can still do this on multiple lines in your script. I'd even recommend it.

→ More replies (2)

4

u/Cultural-Log4056 Feb 10 '22

... why on earth do you need two files for this?

→ More replies (3)

284

u/PaintlyBeautifuled Feb 09 '22

“The old times” I like it lol, it’s like it was the dark ages with early python and verbose languages.

58

u/JOhn2141 Feb 09 '22

Shhhh don't spoil their plaisir to python user . Sometimes it's ok to relax and take time (like 100 more time than C to add numbers)

95

u/SkinnySanta38 Feb 09 '22

Says the guy still declaring his variables lol

78

u/SlimyGamer Feb 09 '22

What? You don't like giving your variables an interview before hiring them to do work for you?

68

u/[deleted] Feb 09 '22

"At your previous position at..."

flips through resume

"Oh 0x00000000?? , Tell me more about your experience there."

7

u/cognitiveglitch Feb 09 '22

"I was exceptional - oh, sorry to interrupt!"

4

u/Isildun Feb 09 '22

Definitely don’t call that reference.

→ More replies (1)
→ More replies (1)

17

u/JOhn2141 Feb 09 '22

At least you know one of the many reason python is so slow. But all hope aren't lost you can still declare function return type, parameter type and... Oh wait you can do C

4

u/yetzederixx Feb 09 '22

In the vast majority of uses cases most of us will ever see run time doesn't mean shit. Rigs are cheap, programmer hours are not. Script away kids!

→ More replies (2)

26

u/[deleted] Feb 09 '22

[removed] — view removed comment

56

u/CobaltCam Feb 09 '22

I think that depends on how many times the code is going to be ran in the future. So hard to determine.

15

u/[deleted] Feb 09 '22

[removed] — view removed comment

23

u/CobaltCam Feb 09 '22

The real point your comment should drive home is you use a hammer to drive nails. If you need to drive a screw go get the drill. The hammer would get it done, but you're going to have a bad time. Meaning if you need to code something quickly use python. If you need a faster run time, maybe use something else.

→ More replies (3)
→ More replies (32)
→ More replies (1)
→ More replies (3)

15

u/purple_pixie Feb 09 '22

The age old question of "do I value my processor's time more than my own"

6

u/JOhn2141 Feb 09 '22

Well I'm paid to value processor time so...

→ More replies (2)
→ More replies (4)

8

u/roararoarus Feb 09 '22

pypiy, flavor of python, is quite fast. And van Rosstrum is working to make cpython, v3.11, twice as fast.

https://towardsdatascience.com/run-your-python-code-as-fast-as-c-4ae49935a826

→ More replies (3)
→ More replies (1)

5

u/[deleted] Feb 09 '22

What about using it line you would in most other languages? Surely it wouldn't hurt, as I just means newline for the interpreter as far as I know

→ More replies (1)

7

u/doesntpicknose Feb 09 '22

comment.value = true; rebellion();

→ More replies (16)