this post was submitted on 11 Dec 2023
1161 points (98.9% liked)

Programmer Humor

32453 readers
616 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Zron@lemmy.world 18 points 11 months ago (1 children)

Because exit might be a variable you use to determine if you should exit. exit() is a function that actually does the exiting.

It’s the difference between pointing at a jogger and saying “run” and actually running after them.

[–] Bronco1676@lemmy.ml 17 points 11 months ago (2 children)

If you have a variable called exit you've overwritten the function in that scope, and won't be able to execute it.

e.g.

>>> exit=1
>>> exit()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not callable
>>>
[–] EmergMemeHologram@startrek.website 17 points 11 months ago

Reminds me of setting pi = 3 in my friends matlab subroutines in school.

[–] peopleproblems@lemmy.world 5 points 11 months ago

wow it does do that. cool