Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
about help
#1
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
Reply
#2
Try:

>>>import os
>>>dir(os)
Paul
kucingkembar likes this post
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#3
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
ndc85430, kucingkembar, rob101 like this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
(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
Reply
#5
The official docs are not a bad place to look:

https://docs.python.org/3/library/os.htm...#module-os
ndc85430 and kucingkembar like this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply
#6
(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,
Reply
#7
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.
rob101 and kucingkembar like this post
Reply
#8
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?
Reply
#9
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)'
rob101 and kucingkembar like this post
Reply
#10
(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
rob101 likes this post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020