msg374260 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-25 12:54 |
>>> (None and True)
>>> print(_)
False
>>> print((None and True)) # Not same?!
None
>>>
This isn't right.
P.S. What component should this be? IDLE? It's the shell, not just IDLE. Core? Not that deep!
|
msg374261 - (view) |
Author: Rémi Lapeyre (remi.lapeyre) * |
Date: 2020-07-25 13:09 |
Hi wyz23x2, did you do that from a clean interpreter?
_ is set to the last non-None result: https://github.com/python/cpython/blob/dd8a93e23b5c4f9290e1cea6183d97eb9b5e61c0/Python/sysmodule.c#L690-L696
So what you are seeing is that (None and True) is None, but _ is set to some value that you got from a previous input.
I think the component for this report is "Interpreter core".
|
msg374262 - (view) |
Author: Rémi Lapeyre (remi.lapeyre) * |
Date: 2020-07-25 13:12 |
This behaviour is documented at https://docs.python.org/3/library/sys.html#sys.displayhook.
|
msg374263 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-25 13:21 |
I think this should be documented more clearly. Or else users might feel surprised:
>>> print(123)
123
>>> _
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> # There is an expression!?
|
msg374264 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2020-07-25 13:25 |
I haven't checked to see what's documented. I'm sure we'd accept a patch that improves the documentation if it's lacking.
|
msg374266 - (view) |
Author: Karthikeyan Singaravelan (xtreak) * |
Date: 2020-07-25 13:32 |
There is also some docs for _ at https://docs.python.org/3/reference/lexical_analysis.html#reserved-classes-of-identifiers
|
msg374267 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-25 13:36 |
But there's nothing in https://docs.python.org/3/tutorial/interpreter.html. It should be stated there.
|
msg374329 - (view) |
Author: Hai Shi (shihai1991) * |
Date: 2020-07-26 16:03 |
>I haven't checked to see what's documented. I'm sure we'd accept a patch that improves the documentation if it's lacking.
+1
|
msg374390 - (view) |
Author: Shubham Kumar Jha (ShubhamKJha) * |
Date: 2020-07-27 15:52 |
The link provided by Karthikeyan Singaravelan doesn't mention that `_` would only get the not-None values. It is a part of interpreter and hence should be documented there. If no one is working on a patch, I would like to submit one.
|
msg374450 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-28 02:05 |
Submmited PR 21650. Should we also mention it in:
https://docs.python.org/3/tutorial/interpreter.html
or
https://docs.python.org/3/tutorial/appendix.html
?
(Matching the title of the issue)
|
msg374451 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2020-07-28 02:11 |
I think it should be mentioned in https://docs.python.org/3/tutorial/appendix.html#tut-interac, since that's the link that https://docs.python.org/3/tutorial/interpreter.html#interactive-mode uses for it's "for more information" link. This seems like a "more information" kind of thing, to me.
|
msg374452 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-28 02:17 |
If no one wants to work on it, I'll pick up that patch.
Should it be section 16.1.5? If not, what section should it fit into?
|
msg374453 - (view) |
Author: Eric V. Smith (eric.smith) * |
Date: 2020-07-28 02:26 |
I think it should be in a new section. But I'd put it as a 16.1.2 and push the others down. It seems like a more important piece of information than shebangs and startup files in interactive mode. Or maybe I'd even put it first.
That said, I'm not terribly great at writing documentation, so you might want some other opinions.
|
msg374454 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-28 02:27 |
I agree it's more important.
Working.
|
msg374455 - (view) |
Author: wyz23x2 (wyz23x2) * |
Date: 2020-07-28 02:38 |
Submmited PR 21651.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:34 | admin | set | github: 85566 |
2020-07-28 12:13:27 | wyz23x2 | set | pull_requests:
- pull_request20790 |
2020-07-28 11:55:15 | wyz23x2 | set | pull_requests:
+ pull_request20802 |
2020-07-28 08:57:05 | wyz23x2 | set | pull_requests:
- pull_request20792 |
2020-07-28 08:03:01 | wyz23x2 | set | pull_requests:
+ pull_request20796 |
2020-07-28 02:38:38 | wyz23x2 | set | messages:
+ msg374455 |
2020-07-28 02:38:01 | wyz23x2 | set | pull_requests:
+ pull_request20792 |
2020-07-28 02:27:33 | wyz23x2 | set | messages:
+ msg374454 |
2020-07-28 02:26:01 | eric.smith | set | messages:
+ msg374453 |
2020-07-28 02:17:02 | wyz23x2 | set | messages:
+ msg374452 |
2020-07-28 02:11:29 | eric.smith | set | messages:
+ msg374451 |
2020-07-28 02:06:42 | wyz23x2 | set | title: Document '_' in interpreter in shell tutorial -> Document '_' in interpreter tutorial |
2020-07-28 02:05:45 | wyz23x2 | set | messages:
+ msg374450 |
2020-07-28 02:02:20 | wyz23x2 | set | keywords:
+ patch stage: patch review pull_requests:
+ pull_request20790 |
2020-07-27 15:52:07 | ShubhamKJha | set | nosy:
+ ShubhamKJha messages:
+ msg374390
|
2020-07-26 16:03:53 | shihai1991 | set | nosy:
+ shihai1991 messages:
+ msg374329
|
2020-07-25 13:37:16 | wyz23x2 | set | nosy:
+ xtreak
|
2020-07-25 13:36:52 | wyz23x2 | set | title: Make '_' behavior in shell more clear -> Document '_' in interpreter in shell tutorial nosy:
- xtreak
messages:
+ msg374267
components:
- Interpreter Core |
2020-07-25 13:32:19 | xtreak | set | nosy:
+ xtreak messages:
+ msg374266
|
2020-07-25 13:25:04 | eric.smith | set | nosy:
+ eric.smith messages:
+ msg374264
|
2020-07-25 13:21:44 | wyz23x2 | set | title: Behiavior of '_' strange in shell -> Make '_' behavior in shell more clear nosy:
+ docs@python
messages:
+ msg374263
assignee: docs@python components:
+ Documentation |
2020-07-25 13:12:46 | remi.lapeyre | set | messages:
+ msg374262 |
2020-07-25 13:09:45 | remi.lapeyre | set | nosy:
+ remi.lapeyre messages:
+ msg374261 components:
+ Interpreter Core
|
2020-07-25 12:54:28 | wyz23x2 | create | |