this post was submitted on 21 Mar 2025
640 points (99.5% liked)

Programmer Humor

21809 readers
1775 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Original post: hachyderm.io (Mastodon)

you are viewing a single comment's thread
view the rest of the comments
[–] Aatube@kbin.melroy.org 16 points 2 days ago (3 children)

Can't they just convert a "true" input to backend to uppercase

[–] PotatoesFall@discuss.tchncs.de 26 points 2 days ago

Yep they should use a config file format like JSON or TOML or YAML or what have you, and then decode that into python objects. Using an actual programming language for config is dumb as hell IMO. (inb4 pissed off suckless fans)

[–] jjjalljs@ttrpg.network 5 points 2 days ago (1 children)

Depends on how it's set up. If the setting is going into the env it's a string, so I'd expect some sort of

if os.getenv("this_variable", "false").lower() == "true":   # or maybe "in true, yes, on, 1" if you want to be weird like yaml
  this_variable = True
else:
  this_variable = False

Except maybe a little more elegant and not typed on my phone.

But if the instructions are telling the user to edit the settings directly, like where I wrote this_variable=True, they'd need to case it correctly there.

[–] fushuan@lemm.ee 2 points 1 day ago (1 children)

Fyi, using a condition to assign a boolean is equivalent to assigning the condition itself. No need for the IF.

[–] jjjalljs@ttrpg.network 1 points 1 day ago

true, though sometimes i find the more verbose style easier to read, and more maintainable (eg: you want to do something else in the block, you can just add a line instead of changing your ternary / etc). Small things

[–] hersh@literature.cafe 4 points 2 days ago

I refer you to #7 on Bruce Tognazzini's evergreen top ten list of design bugs.

https://www.asktog.com/Bughouse/10MostWantedDesignBugs.html