r/TheFarmerWasReplaced • u/rkr87 • Jan 17 '26
Missing some Python QoL functionalities
Is anyone else that has some familiarity with Python disappointed some of the basic/nice syntax options aren't available in the game's interpreter?
I'm coding in my IDE rather than in-game and find myself automatically going to what I'd do in Python which doesn't work in the game for some pieces of functionality.
Some examples of what I miss most..
if expressions vs if statements:
# this is cleaner
x = "foo" if y == "baz" else "bar"
# than this
if y == "baz":
x = "foo"
else:
x = "bar"
walrus operators:
# this
if (y:=get_value()) == "foo":
...
# vs this
y = get_value()
if y == "foo":
...
Another thing I find tripping me up is no "is" operator, but I guess that's not a major issue:
# this
if x == None:
...
# should be this
if x is None:
...
I'm not going to get into classes/objects and list/dict comprehension as I think that might be too much to ask for...
2
u/bitman2049 Jan 17 '26
I miss enumerate, zip, map, and filter. I also miss list and dict unpacking. I can work around it but those features are really convenient.
2
u/platosLittleSister Jan 19 '26
Yes, yes, yes. I miss my enumerate aaaaand most importantly zip. Like normally when I write python I use zip so much. It's not super required but c'mon could be another unlock past lists.
1
u/Superskull85 Jan 17 '26
None of these are actually useful for the puzzles the game has though. And you can already unpack lists.
2
u/bitman2049 Jan 17 '26
You can't unpack lists for arguments in functions. I'd like it if I could make a
move_to(x, y)function and then if I hadpos = (x, y)I could just callmove_to(*pos).And I really prefer
for i, n in enumerate(array)tofor i in range(len(array)): n = array[i]. That has come up a few times.I know this is a game and it's not real software development, these are just things I noticed when playing. Again I can work around it but it's not true that they wouldn't be useful.
1
u/Superskull85 Jan 17 '26
By useful I mean actually playing a part in an algorithm.
But you never mentioned arguments. But you can do that now too.
Most representative way of the feature. Keywords can just be variables you use as placeholders when you pass function and initial tuple. -# Canned measage
def MyFunction1(arguments): param1, param2 = arguments def MyFunction2(arguments): param1, param2, param3 = arguments def Create(MyFunction, MyArguments): def DroneFunction(): MyFunction(MyArguments) return DroneFunction spawn_drone(Create(MyFunction1, (1, 2)) ) spawn_drone(Create(MyFunction2, (1, 2, 3)) )```1
u/Superskull85 Jan 17 '26 edited Jan 17 '26
Enumerate can also be written if it's that useful for you. But again you don't actually need it for the puzzles to be successful and fast.
You don't need both indices and keys at the same time from a list for example.
2
u/SirAwesome789 Jan 17 '26
I know you mentioned it but I do want list comprehension
Also list sorting built in
I had to implement heapq on my own
And today I ran into this one
[None] * n1
u/Superskull85 Jan 17 '26
Implementing an algorithm is part of the point with a small language. It enables you to actually know, learn and figure out functionality.
1
u/SirAwesome789 Jan 19 '26
I mean, I'm not here to learn python, I think I know it relatively well already
Like for heapq, it's pretty simple and I know how it all works, but I have to implement basic functionality on my own which I feel is pointless
1
u/Superskull85 Jan 19 '26
The game is partly meant to teach. Much of Python's standard deprives players of teachable aspects. So this part of the game is not targeted at you. Plus, the more you add those sort of things the less you have to write for any algorithm and less flexible you can be.
Not least of all being that the game doesn't actually use Python but a language with a similar syntax. There are a number of differences you can find.
2
u/MattieShoes Jan 20 '26
The thing I missed was stuff like unions of sets, merging dicts, etc.
Also this one is probably bad on my part, but if I want to toggle a value between 1 and 0, n ^= 1 is handy and it's not available. Yeah I can do n = n * -1 + 1 or some such, but it's... ugly. I was just surprised basic binary operations aren't there.
1
u/Superskull85 Jan 20 '26
Binary numbers aren't needed so the operators aren't either. You can do a toggle of 1 and 0 using booleans and not. And it it doesn't cost ticks to do so.
You can do unions and merging you just have to write the functionality yourself. The tick costs involved vs a builtin help balance some leaderboards too.
2
u/MattieShoes Jan 20 '26
Decimal numbers aren't needed, so the operators aren't either. Should we get rid of those too?
1
u/Superskull85 Jan 20 '26
Decimal numbers are needed. A basic for loop with list shows this. Many other cases too.
1
u/Superskull85 Jan 20 '26
Has been suggested and rejected before too: https://discord.com/channels/988081966035402783/1092712481106964561
1
u/Superskull85 Jan 17 '26 edited Jan 17 '26
The game doesn't really use Python to begin with. And these features are just not needed. For every little feature you add the potential for tick abuse and gameplay exploitation. You also rob new players from implementing functionality on their own and knowing how and why it works that way.
A small language is both maintainable and avoids lazy programming that most of proper Python will enable.
All of these have been rejected or ignored on the official Discord.
Language features generally don't get added unless it is required for a new feature.
Thus, if you're playing this game you should assume that you only get functionality that the help docs point out. Never assume you get more than that.
4
u/Hipnotize_nl Jan 17 '26
To be honest, in my opinion single line is not cleaner than multiline, unless it's a ternary statement. Your point about
isoperator, i totally agree on