5 ms·
I hate when a program tells me what I have to do. I always think "damn it program, if you know what to do, just do it already. I say what to do, and you do it".
by forty 5y ago
I hate when a program tells me what I have to do. I always think "damn it program, if you know what to do, just do it already. I say what to do, and you do it".
For example when terraform tells me to run "terraform init", as if actually typing the letters on the keyboard had any benefit...
- skykooler 5y agoSame thing with Python: >>> help Type help() for interactive help, or help(object) for help about object. >>> exit Use exit() or Ctrl-D (i.e. EOF) to exit If you know what I'm trying to do, then just do it!
- dataflow 5y ago>>> print "hi" SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? I would be in favor of that for this one!
- 3np 5y agoThat was the behavior in python2 and it was changed for good reason. If you do want this, consider ipython as your Python REPL. https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-autocall https://ipython.readthedocs.io/en/stable/interactive/magics....
- dataflow 5y agoYes, hence the semi-joke. But I actually do think it was a good feature and a bad idea to remove it.
- usui 5y agoIsn't this due to some REPL-constraints or not wanting to break the way the language works? Maybe there's no way to evaluate the "exit" and "help" objects replaced by "exit()" and "help()", and that making exceptions would clutter the code. Not sure the reasoning behind it, but that's what it seems.
- lou1306 5y ago> not wanting to break the way the language works This is the reason. "help" and "exit" (as well as "quit") are perfectly cromulent variable names in Python. So the REPL does the best possible thing, i.e., try and evaluate the expression and shoot a message if it fails. Case in point: >>> help = "hi" >>> help "hi" >>> del help >>> help Type help() for interactive help, or help(object) for help about object.
- blt 5y agoWhy not: - check if a variable called "help" is in scope - if not, call help(). - otherwise, print its value.
- Brian_K_White 5y agoBecause then when there IS a variable, the help command you learned will not work. I think anyone crying and baffled about this is fundamentally not well suited to programming. This sort of logical problem should be intuitive. The seeming irrationality of the special case behavior is just something funny to make your mom laugh, not something that's actually illogical or inconsistent or stupid.
- lou1306 5y agoWhat if you have defined a "help()" function though? REPL should be as dumb as possible. That's a feature, not a bug.
- david2ndaccount 5y agoThere’s nothing special about those variables besides them being builtins. Those messages are actually just the __repr__ for each.
- contravariant 5y agoYou could make `exit` quit the application when __repr__ is called. Not sure if this is a good idea however.
- 3np 5y agoIt doesn't know what you're trying to do, it can just make a best-effort guess, which may be wrong. Maybe you are deep inside a session, trying to inspect a variable or function called `exit` that just doesn't happen to be in scope like you expect? Exiting the process at that point could be terrible and the impact of the lost state exceed the lifetime-accumulated lost seconds that would have been saved by being "helpful". If you really want this, consider using ipython with %autocall as your Python REPL. https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-autocall https://ipython.readthedocs.io/en/stable/interactive/magics....
- roelschroeven 5y agoIt's worse: Type "help", "copyright", "credits" or "license()" for more information. >>> help Type help() for interactive help, or help(object) for help about object. >>> Python tells you to type "help", but when you do it turns out that that doesn't do much. I get it, they want to make the distinction between help() and help(object), but I feel that could have done a bit more friendly.
- glandium 5y agoMy "favorite" one of those is Mercurial's error when you use a subcommand that you need to enable an extension for. Not only does it know the subcommand is valid, it also tells you which extension to enable. If it's gone all that way, why not enable the extension automatically?