It's fine if you have strings you're using over and over again. You don't want magic strings littered all over your code. However, it looks like they're just using these variables once to build a string once. Just write out the single string.
. su is an Internet country code top-level domain (ccTLD) that was designated for the Soviet Union (USSR) on 19 September 1990. Even though the Soviet Union itself was dissolved a mere 15 months later, the . su top-level domain remains in use today with over 100,000 .
No part of what’s being put into the server string is actually dynamic, so creating temporarily variables that look an awful lot like what the strings they’re representing is just taking up space and making it less straightforward
It's needless overhead to format strings, especially with things which really won't end up changing in the lifetime of this app. I think it's safe to say "https" can be hardcoded.
If any of these are meant to be constants you should uppercase them if you want to be pythonic. It's a good practice since you can't actually declare a constant in python. https://www.python.org/dev/peps/pep-0008/#constants
262
u/jesp1999 Aug 09 '21
f"{server}"
216
u/matt1484 if true else false Aug 09 '21
Employment status might change with code that bad
136
u/gipp Aug 09 '21
.com is forever though
34
u/Tannslee Aug 09 '21
Didn't even account for the ".com", what if it changes?
59
u/alexanderhameowlton Aug 09 '21 edited Aug 09 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
84
u/arnitdo Aug 09 '21
YOU GET AN F STRING! YOU GET AN F STRING! EVERYONE GETS AN F STRING!
54
u/InvalidUsername2404 Aug 09 '21
This hurs
43
u/CardRat Aug 09 '21
The http = “https” part hurts me the most
17
u/GoncaloRod Aug 09 '21
He forgot the
.com, completely unmaintainable....87
u/Spare_Competition Aug 09 '21
Just do
url = "https://discord.com/api/webhooks". You keep the ability to change it in the future, but it’s no longer a huge mess24
u/mailslot Aug 09 '21
I’m more upset that “server” isn’t also four characters, than it’s actually a URI.
11
u/Franks2000inchTV Aug 10 '21
Is this the /r/badcode version of typing someemail [at] gmail [dot] com?
30
u/_pestarzt_ Aug 09 '21
18
u/oM4TY Aug 09 '21
When employer says your code should have at least 400 lines
9
u/Bit5keptical Aug 10 '21
http = "https"
5
u/[deleted] Aug 10 '21
When we have the "super safe" HTTP protocol it's gonna be httpss://
4
u/using_mirror Aug 10 '21
Ughhhh webh is declared before aapl when aapl is used before webh... It doesn’t even read remotely well
2
u/FGaBoX_ Aug 10 '21
This is painful to watch
2
u/infamous_redditor Aug 10 '21
Oh so that's what my techlead means when he says we need highly maintainable code
2
u/lilloet Aug 11 '21
This looks like a simple obfuscation attempt by a malicious code, this is done to escape simple signature based antivirus detections.
6
u/[deleted] Aug 09 '21
... I don't think this is terrible? Someone tell me why I'm wrong.
1
u/bwz3r Aug 10 '21
Uhhhh
1
u/[deleted] Aug 10 '21
This looks like my code after me pussying out and accepting all stupid code review comments
1
u/lizardturtle shameless Aug 10 '21
Oh my god I'm gonna puke. WHY???
1
u/_default_username Aug 16 '21
If any of these are meant to be constants you should uppercase them if you want to be pythonic. It's a good practice since you can't actually declare a constant in python. https://www.python.org/dev/peps/pep-0008/#constants
1
u/SaltyMini Aug 09 '21
How else would you do this?
8
u/[deleted] Aug 10 '21
[removed] — view removed comment