Python Forum

Full Version: about help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
sorry for my bad English,
how to get to know all syntax or their explanation of a module or package,
for example:
import os
we know there is some syntax like
os.mkdir()
os.remove()
but how do I do if I like to know there is another syntax in the os package,
(except going to google of course)

thank you for reading, have a nice day
Try:

>>>import os
>>>dir(os)
Paul
Always, check the docs
https://docs.python.org/3/
In this case - the Library reference or module index
https://docs.python.org/3/library/index.html
https://docs.python.org/3/py-modindex.html
(Sep-27-2022, 05:16 PM)DPaul Wrote: [ -> ]Try:

>>>import os
>>>dir(os)
Paul
thank you Paul, sorry for very basic, I have trouble the keyword in the google,
I will ad you a reputation point
The official docs are not a bad place to look:

https://docs.python.org/3/library/os.htm...#module-os
(Sep-27-2022, 05:21 PM)buran Wrote: [ -> ]Always, check the docs
https://docs.python.org/3/
In this case - the Library reference or module index
https://docs.python.org/3/library/index.html
https://docs.python.org/3/py-modindex.html

thank you for the info buran,
Or you can ask for help

I wrote this file named test.py
def countdown(arg):
    """Does some stuff"""
    return arg**2
When I import and ask for help I get this
Output:
>>> import test >>> help(test) Help on module test: NAME test FUNCTIONS countdown(arg) Does some stuff FILE ...\test.py
The help will be better, and much longer, for the standard libraries and built in modules.
sorry for additional question,
i do this code:
import os
os.mkdir(
then a hintbox written:
Output:
(path, mode=511, *, dir_fd=None) Create a directory.
how to show this?
All the information is available. Your GUI sees you typed os.mkdir( and it goes to get os.mkdir.__text_signature__. help() uses that along with mkdir.__doc__.
Output:
>>> import os >>> help(os.mkdir) Help on built-in function mkdir in module nt: mkdir(path, mode=511, *, dir_fd=None) Create a directory. If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path will then be relative to that directory. dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError. The mode argument is ignored on Windows. >>> dir(os.mkdir) ['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__'] >>> os.mkdir.__doc__ 'Create a directory.\n\nIf dir_fd is not None, it should be a file descriptor open to a directory,\n and path should be relative; path will then be relative to that directory.\ndir_fd may not be implemented on your platform.\n If it is unavailable, using it will raise a NotImplementedError.\n\nThe mode argument is ignored on Windows.' >>> os.mkdir.__text_signature__ '($module, /, path, mode=511, *, dir_fd=None)'
(Sep-27-2022, 06:06 PM)deanhystad Wrote: [ -> ]All the information is available. Your GUI sees you typed os.mkdir( and it goes to get os.mkdir.__text_signature__. help() uses that along with mkdir.__doc__.
Output:
>>> import os >>> help(os.mkdir) Help on built-in function mkdir in module nt: mkdir(path, mode=511, *, dir_fd=None) Create a directory. If dir_fd is not None, it should be a file descriptor open to a directory, and path should be relative; path will then be relative to that directory. dir_fd may not be implemented on your platform. If it is unavailable, using it will raise a NotImplementedError. The mode argument is ignored on Windows. >>> dir(os.mkdir) ['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__text_signature__'] >>> os.mkdir.__doc__ 'Create a directory.\n\nIf dir_fd is not None, it should be a file descriptor open to a directory,\n and path should be relative; path will then be relative to that directory.\ndir_fd may not be implemented on your platform.\n If it is unavailable, using it will raise a NotImplementedError.\n\nThe mode argument is ignored on Windows.' >>> os.mkdir.__text_signature__ '($module, /, path, mode=511, *, dir_fd=None)'
that is what I looking for, thank you, I will add you reputation point
Pages: 1 2