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

Implement the help() builtin #1425

Closed
dralley opened this issue Sep 27, 2019 · 4 comments
Closed

Implement the help() builtin #1425

dralley opened this issue Sep 27, 2019 · 4 comments
Labels
C-compat A discrepancy between RustPython and CPython

Comments

@dralley
Copy link
Contributor

dralley commented Sep 27, 2019

Expected

Brings up a docs page for the object passed in

Help on dict object:

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |      (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in iterable:
 |          d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |      in the keyword argument list.  For example:  dict(one=1, two=2)
 |  
 |  Methods defined here:
 |  
 |  __contains__(self, key, /)
 |      True if the dictionary has the specified key, else False.
 |  
 |  __delitem__(self, key, /)
 |      Delete self[key].
 |  
 |  __eq__(self, value, /)
 |      Return self==value.
 | .............
 | ............

Actual

>>>>> help({})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'help' is not defined

Python Documentation

https://docs.python.org/3/library/functions.html#help

@dralley dralley added the C-compat A discrepancy between RustPython and CPython label Sep 27, 2019
@coolreader18
Copy link
Member

This is added by the site module on startup (which we have), we just aren't able to import pydoc yet so it doesn't work.

@windelbouwman
Copy link
Contributor

So the challenge becomes to import pydoc?

@coolreader18
Copy link
Member

Yep!

@dbrgn
Copy link
Contributor

dbrgn commented Feb 5, 2021

It seems that this works now, and that the issue can be closed!

>>>>> help({})
Help on dict object:

class dict(object)
 |  dict() -> new empty dictionary
 |  dict(mapping) -> new dictionary initialized from a mapping object's
 |  (key, value) pairs
 |  dict(iterable) -> new dictionary initialized as if via:
 |  d = {}
 |  for k, v in iterable:
 |  d[k] = v
 |  dict(**kwargs) -> new dictionary initialized with the name=value pairs
 |  in the keyword argument list.  For example:  dict(one=1, two=2)
 |
 |  Methods defined here:
 |
 |  __bool__(...)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-compat A discrepancy between RustPython and CPython
Projects
None yet
Development

No branches or pull requests

4 participants