I don’t python, but I know there’s tons of ()
why is there so much () and other empty brackets?
Comment on Anon is a linguist
renzhexiangjiao@piefed.blahaj.zone 5 days ago
to me method names are imperatives, like when we order the dog to walk.
dog.walk() = “Dog, walk!”
I don’t python, but I know there’s tons of ()
why is there so much () and other empty brackets?
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, like.
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.
Okay, cool, thanks! :D
alias_qr_rainmaker@lemmy.world 5 days ago
i know that’s how you’re supposed to read it…and guess what…it’s wrong
Tetragrade@leminal.space 3 days ago
Image
JackbyDev@programming.dev 3 days ago
How do you tell a dog to walk? “Dog, walks!” or “Dog, walk!”
alias_qr_rainmaker@lemmy.world 3 days ago
i’m not telling the dog to walk, i’m describing it walking
FooBarrington@lemmy.world 3 days ago
But the dog can fail to walk before he ever walked, so you’re not describing him walking, you’re telling him to start walking.
JackbyDev@programming.dev 3 days ago
Python is an imperative language.
fushuan@lemmy.blahaj.zone 3 days ago
Python is not a descriptive language, it’s a commands based language.
Go do functional programming if you want to describe instead of command.
Transpiling python and describing stuff when actually you are commanding is overly backwards and stupid, but I’d not expect anything else from a 4chan post. XD
Camille_Jamal@sh.itjust.works 3 days ago
Elaborate?