Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...



My "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?


Same 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!


It 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....


It'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.


  >>> print "hi"
  SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I would be in favor of that for this one!


That 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....


Yes, hence the semi-joke. But I actually do think it was a good feature and a bad idea to remove it.


Isn'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.


> 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.


Why not:

    - check if a variable called "help" is in scope
    - if not, call help().
    - otherwise, print its value.


Because 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.


What if you have defined a "help()" function though?

REPL should be as dumb as possible. That's a feature, not a bug.


There’s nothing special about those variables besides them being builtins. Those messages are actually just the __repr__ for each.


You could make `exit` quit the application when __repr__ is called.

Not sure if this is a good idea however.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: