this post was submitted on 13 Dec 2025
262 points (95.5% liked)

Greentext

7465 readers
1120 users here now

This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.

Be warned:

If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] renzhexiangjiao@piefed.blahaj.zone 56 points 2 days ago (11 children)

to me method names are imperatives, like when we order the dog to walk.

dog.walk() = "Dog, walk!"

[–] Camille_Jamal@sh.itjust.works 3 points 1 day ago (1 children)

I don't python, but I know there's tons of ()

why is there so much () and other empty brackets?

[–] yetAnotherUser@discuss.tchncs.de 8 points 1 day ago* (last edited 22 hours ago)

It's calling a function without a parameter.

You know how in math you had something like:

f(x) = x²

Not all functions need parameters though. The function:

f(x) = 2

does not even use the provided x! So just leave it out:

f() = 2

Similarly, you could give a function two parameters:

f(x, y) = x + y

Programmers use functions to primarily organize their code. Otherwise it would get very unreadable very quickly. Those function are usually a bit more complicated than a single line, though.

dog.walk() would call the walk() function of "dog". Some valid code could be:

dog.walk()
wait(10)
dog.stop()

This code would make the dog walk for 10 seconds assuming every function used is actually defined somewhere.

load more comments (9 replies)