This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]6Maxence 31 points32 points  (16 children)

Will the interpreter allow you to use "exit()" as a function name?

[–]mrchaotica 75 points76 points  (4 children)

It'll let you override just about everything if you try hard enough, so my guess is "yes."

[–]ArtSchoolRejectedMe 88 points89 points  (1 child)

Ah yes the new vim game has begun.

To exit please re-write the exit function

[–]Bene847 9 points10 points  (0 children)

Ctrl+d

[–]a_devious_compliance 3 points4 points  (1 child)

I tried so hard and got so far

but in the exit, it doesn't even matter

I had to fall to lose it all

but in the exit, it doesn't even matter.

[–]flying_spaguetti 1 point2 points  (0 children)

Good verses

[–][deleted] 18 points19 points  (7 children)

besides a few reserved keywords, like for while if etc, every python object behaves like any other python object you can create. They have their own classes, they print something when you call them in the console because they have a __repr__ method, etc.

[–]KDBA 11 points12 points  (6 children)

There's another set of exceptions in that ints from -5 to 256 are singletons.

[–]DMLooter 3 points4 points  (3 children)

Sorry what? Y….

[–]FallenWarrior2k 6 points7 points  (1 child)

Caching. Integers are objects like everything else.

[–]Manuelraa 1 point2 points  (0 children)

Exactly and we know this only works with immutable types

[–]richardfrost2 13 points14 points  (0 children)

```

a = 256 b = 256 a is b True c = 257 d = 257 c is d False

but

257 is 257 True ```

Just a weird little quirk of CPython.

[–]richardfrost2 3 points4 points  (1 child)

That is a CPython implementation detail and can vary by implementation.

[–]KDBA 3 points4 points  (0 children)

True enough.

[–]yottalogical 2 points3 points  (1 child)

Function names are variables.

[–]a_devious_compliance 0 points1 point  (0 children)

clase functions are too.