Re:How Many Lines of C It Takes to Execute a and B in Python?
by mseepgood on Monday December 11, 2023 @09:38AM
(#38601008)
If this is by design and it optimizes for simplicity and easy interoperability with C, why would you assess its quality as 'good software' based on criteria that are non-goals?
[ Parent
| on HN ]
Re:How Many Lines of C It Takes to Execute a and B in Python?
by Asraelite on Monday December 11, 2023 @10:13AM
(#38601321)
In my eyes, "good software" does not necessarily just mean something that accomplishes its goals. You can set a goal of being bad, and that's kind of what CPython is doing.
Of course, "good" and "bad" are relative. If you don't care about performance then there's nothing wrong with CPython.
Re:How Many Lines of C It Takes to Execute a and B in Python?
by acqq on Monday December 11, 2023 @12:21PM
(#38602465)
I agree with that estimate, I think it was really the idea of Python to be less than "good" by design.
I mean one doesn't need more than:
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
to see. They have that special handling, but they still don't want to let you out, because... IMO, they just want to be annoying.When a solution could be something like:
Note: exit() is needed in scripts. In this prompt Ctrl-D (i.e. EOF) can also be used.
Exiting.
Re:How Many Lines of C It Takes to Execute a and B in Python?
by monoprotic on Monday December 11, 2023 @01:17PM
(#38603269)
There has been discussion of this change a few times, e.g. https://bugs.python.org/issue44603
I generally agree with your overall sentiment, but I think it's important to note that the behavior is _not_ special handling; it's just the normal `repr` behavior at the REPL, where `exit` is an object like any other, and `repr(exit)` is that message.
Re:How Many Lines of C It Takes to Execute a and B in Python?
by acqq on Wednesday December 13, 2023 @08:58AM
(#38627402)
Whoever types exit in REPL will never care what "repr(exit)" does.
Python has a lot excuses about the need to remain "consistent" but the reality isn't so:
>>> x = open( "/tmp/whatever123", "w" )
>>> close( x )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'close' is not defined. Did you mean: 'cosh'?
...
>>> x.close()
>>>
>>> x = "tttt"
>>> x.len()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...
>>> len( x )
4
Re:How Many Lines of C It Takes to Execute a and B in Python?
by zitterbewegung on Monday December 11, 2023 @02:46PM
(#38604533)
I think this is to be consistent that exit is not a statement but a function. This was done with print. 3.0 was an ergonomic fix for cpython developers and language consistency fixes (also redoing the Unicode implementation).
Re:How Many Lines of C It Takes to Execute a and B in Python?
by heyodai on Monday December 11, 2023 @12:57PM
(#38602969)
Yeah, that message is a pet peeve of mine. Like, you know what I'm trying to do.
Re:How Many Lines of C It Takes to Execute a and B in Python?
by Smaug123 on Monday December 11, 2023 @01:43PM
(#38603667)
It sort of doesn't! It's just doing exactly the same thing it would do with any other identifier: it's printing its `repr`. Try `repr(exit)`!
Re:How Many Lines of C It Takes to Execute a and B in Python?
by a1369209993 on Monday December 11, 2023 @04:53PM
(#38606038)
More to the point, try `[len,exit,repr]`. Consider what would happen if `exit.__repr__()` did terminate the program.