Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation strings not accessible via REPL #1481

Closed
raenye opened this issue Dec 12, 2020 · 1 comment
Closed

Documentation strings not accessible via REPL #1481

raenye opened this issue Dec 12, 2020 · 1 comment
Milestone

Comments

@raenye
Copy link

raenye commented Dec 12, 2020

The following code behaves differently when typed in the REPL shell and when run from a script:

def f():
    "doc string"
    pass

REPL (Thonny)

>>> help(f)
Help on function f in module __main__:

f()
>>> f.__doc__ is None
True

Script (Thonny)

>>> %Run scratch.py
>>> help(f)
Help on function f in module __main__:

f()
    doc string
>>> f.__doc__
'doc string'

REPL (official CPython)

>>> help(f)
Help on function f in module __main__:

f(x)
    doc string
>>> f.__doc__
'doc string'

Is this intentional?

Thanks,
R.

@aivarannamaa
Copy link
Member

Thank you for the report!

It was not intentional. I had made a mistake in emulating Python REPL, which prints the value of each "bare" expression (ie. ast.Expr node). I forgot, that the docstring is an exception to this.

Should be fixed now.

@aivarannamaa aivarannamaa added this to the 3.3.2 milestone Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants