-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[New Term] Python Built-in Functions: help()
#1486
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97d0552
add new term entry about the help() function
alenn97 f61a7ed
add shell block for output section
alenn97 413a2f8
modify line 57
alenn97 24c2720
Merge branch 'main' into help_command
alenn97 7c24629
Merge branch 'main' into help_command
SSwiniarski 54d8f91
modify text according to reviews
alenn97 a2554df
Merge branch 'main' into help_command
SSwiniarski 1699869
Update help.md
Dusch4593 6efe07d
Merge branch 'main' into help_command
Dusch4593 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
content/python/concepts/built-in-functions/terms/help/help.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| --- | ||
| Title: 'help()' | ||
| Description: 'Displays documentation of an object using the Python help utility.' | ||
| Subjects: | ||
| - 'Computer Science' | ||
| - 'Data Science' | ||
| Tags: | ||
| - 'Documentation' | ||
| - 'Functions' | ||
| - 'Methods' | ||
| CatalogContent: | ||
| - 'learn-python-3' | ||
| - 'paths/computer-science' | ||
| --- | ||
|
|
||
| The **`help()`** displays documentation about various Python objects including [modules](https://www.codecademy.com/resources/docs/python/modules), [functions](https://www.codecademy.com/resources/docs/python/functions), [classes](https://www.codecademy.com/resources/docs/python/classes), and [keywords](https://www.codecademy.com/resources/docs/python/keywords). If no argument is passed, the interactive help utility starts up on the [command line](https://www.codecademy.com/resources/docs/command-line). | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```pseudo | ||
| help(object) | ||
| ``` | ||
|
|
||
| When an `object` parameter is not passed to the `help()` function, the interactive help utility will be started. | ||
|
|
||
| If the `object` is a [string](https://www.codecademy.com/resources/docs/python/strings) that matches a valid module, function, class, keyword, or other topic, a documentation page will be displayed. For other kinds of objects (like a [tuple](https://www.codecademy.com/resources/docs/python/tuples)), the `help()` function will show its documentation page as well. | ||
|
|
||
| ## Example | ||
|
|
||
| Calling the `help()` function without an argument, the following output is returned: | ||
|
|
||
| ```shell | ||
| Welcome to Python 3's help utility! | ||
|
|
||
| If this is your first time using Python, you should definitely check out | ||
| the tutorial on the internet at https://docs.python.org/3.10/tutorial/. | ||
|
|
||
| Enter the name of any module, keyword, or topic to get help on writing | ||
| Python programs and using Python modules. To quit this help utility and | ||
| return to the interpreter, just type "quit". | ||
|
|
||
| To get a list of available modules, keywords, symbols, or topics, type | ||
| "modules", "keywords", "symbols", or "topics". Each module also comes | ||
| with a one-line summary of what it does; to list the modules whose name | ||
| or summary contain a given string such as "spam", type "modules spam". | ||
|
|
||
| help> | ||
| ``` | ||
|
|
||
| The following shows how the `help()` function provides information about Python's built-in [`print()`](https://www.codecademy.com/resources/docs/python/built-in-functions/print) function: | ||
|
|
||
| ```py | ||
| help(print) | ||
| ``` | ||
|
|
||
| This produces the following output: | ||
|
|
||
| ```shell | ||
| print(...) | ||
| print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) | ||
|
|
||
| Prints the values to a stream, or to sys.stdout by default. | ||
| Optional keyword arguments: | ||
| file: a file-like object (stream); defaults to the current sys.stdout. | ||
| sep: string inserted between values, default a space. | ||
| end: string appended after the last value, default a newline. | ||
| flush: whether to forcibly flush the stream. | ||
| ``` | ||
|
|
||
| ## Codebyte Example | ||
|
|
||
alenn97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| The following example is runnable and shows how the `help()` function can be applied to different kinds of objects, including user-defined classes: | ||
|
|
||
| ```codebyte/python | ||
| import math | ||
|
|
||
| class newClass: | ||
| x = 5 | ||
|
|
||
| # class | ||
| help(newClass) | ||
|
|
||
| # module | ||
| help(math) | ||
|
|
||
| # function | ||
| help(print) | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.