From 97d0552e8f166bf8bacc6462311196ba1f2bf47f Mon Sep 17 00:00:00 2001 From: alenn97 Date: Wed, 11 Jan 2023 17:27:41 +0100 Subject: [PATCH 1/5] add new term entry about the help() function --- .../built-in-functions/terms/help/help.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 content/python/concepts/built-in-functions/terms/help/help.md diff --git a/content/python/concepts/built-in-functions/terms/help/help.md b/content/python/concepts/built-in-functions/terms/help/help.md new file mode 100644 index 00000000000..5ea5f83b1b3 --- /dev/null +++ b/content/python/concepts/built-in-functions/terms/help/help.md @@ -0,0 +1,89 @@ +--- +Title: 'help()' +Description: 'Display the documentation of the object passed as argument.' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Functions' + - 'Methods' +CatalogContent: + - 'learn-python-3' + - 'paths/computer-science' +--- + +The `help()` function accepts an object as a parameter, which is a module, function, class or keyword. After being called, the documentation of the requested object is displayed. +If no argument is passed the interactive help utility starts up on the console. + +## Syntax + +The object is passed to the `help()` function as parameter: + +```pseudo +help(object) +``` + +To start the interactive help utility, the function is called without argument: + +```pseudo +help() +``` + +## Example + +Below is an example where a build-in function is passed as argument: + +```py +help(print) +# Output: +# 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. + +``` + +If no argument is present: + +```py +help() +# Output: +# 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> +``` + +## Codebyte Example + +```codebyte/py +import math + +class newClass: + x = 5 + +# class +help(newClass) + +# module +help(math) + +# function +help(print) +``` From f61a7edca8c633711339e3bae5ab3abfd04bbde8 Mon Sep 17 00:00:00 2001 From: alenn97 Date: Thu, 12 Jan 2023 11:02:03 +0100 Subject: [PATCH 2/5] add shell block for output section --- .../built-in-functions/terms/help/help.md | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/content/python/concepts/built-in-functions/terms/help/help.md b/content/python/concepts/built-in-functions/terms/help/help.md index 5ea5f83b1b3..84ae7c65f2b 100644 --- a/content/python/concepts/built-in-functions/terms/help/help.md +++ b/content/python/concepts/built-in-functions/terms/help/help.md @@ -35,39 +35,42 @@ Below is an example where a build-in function is passed as argument: ```py help(print) -# Output: -# 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. - +``` +Which 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. ``` If no argument is present: ```py help() -# Output: -# 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> +``` +Which returns: +```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> ``` ## Codebyte Example From 413a2f896b7cd6f7360cb264279fb01962aef5ba Mon Sep 17 00:00:00 2001 From: alenn97 Date: Thu, 12 Jan 2023 21:24:56 +0100 Subject: [PATCH 3/5] modify line 57 --- content/python/concepts/built-in-functions/terms/help/help.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/python/concepts/built-in-functions/terms/help/help.md b/content/python/concepts/built-in-functions/terms/help/help.md index 84ae7c65f2b..45ebbe7b599 100644 --- a/content/python/concepts/built-in-functions/terms/help/help.md +++ b/content/python/concepts/built-in-functions/terms/help/help.md @@ -28,7 +28,7 @@ To start the interactive help utility, the function is called without argument: ```pseudo help() ``` - + ## Example Below is an example where a build-in function is passed as argument: @@ -54,7 +54,7 @@ If no argument is present: ```py help() ``` -Which returns: +Which returns as output: ```shell Welcome to Python 3's help utility! From 54d8f915d4429c92136610da5259ccd7ad92b7f6 Mon Sep 17 00:00:00 2001 From: alenn97 Date: Sun, 15 Jan 2023 21:10:22 +0100 Subject: [PATCH 4/5] modify text according to reviews --- .../built-in-functions/terms/help/help.md | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/content/python/concepts/built-in-functions/terms/help/help.md b/content/python/concepts/built-in-functions/terms/help/help.md index 45ebbe7b599..865c8d77cac 100644 --- a/content/python/concepts/built-in-functions/terms/help/help.md +++ b/content/python/concepts/built-in-functions/terms/help/help.md @@ -1,10 +1,11 @@ --- Title: 'help()' -Description: 'Display the documentation of the object passed as argument.' +Description: 'Displays documentation of an object using the Python help utility.' Subjects: - 'Computer Science' - 'Data Science' Tags: + - 'Documentation' - 'Functions' - 'Methods' CatalogContent: @@ -12,49 +13,23 @@ CatalogContent: - 'paths/computer-science' --- -The `help()` function accepts an object as a parameter, which is a module, function, class or keyword. After being called, the documentation of the requested object is displayed. -If no argument is passed the interactive help utility starts up on the console. +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 -The object is passed to the `help()` function as parameter: - ```pseudo help(object) ``` -To start the interactive help utility, the function is called without argument: - -```pseudo -help() -``` - -## Example +The object is passed to the `help()` function as parameter. +If an `object` is not provided, the interactive help utility will be started. -Below is an example where a build-in function is passed as argument: +If the `object` is a [string](https://www.codecademy.com/resources/docs/python/strings) that matches to 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()` will show its documentation page. -```py -help(print) -``` -Which 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. -``` +## Example -If no argument is present: +Calling the `help()` function without argument, the following output is returned: -```py -help() -``` -Which returns as output: ```shell Welcome to Python 3's help utility! @@ -73,9 +48,33 @@ 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 -```codebyte/py +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: From 16998697d3d361288555e7e4d72ea6c13c91d84f Mon Sep 17 00:00:00 2001 From: Brandon Dusch Date: Tue, 17 Jan 2023 11:59:42 -0500 Subject: [PATCH 5/5] Update help.md --- .../concepts/built-in-functions/terms/help/help.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/content/python/concepts/built-in-functions/terms/help/help.md b/content/python/concepts/built-in-functions/terms/help/help.md index 865c8d77cac..f277351d9ca 100644 --- a/content/python/concepts/built-in-functions/terms/help/help.md +++ b/content/python/concepts/built-in-functions/terms/help/help.md @@ -21,14 +21,13 @@ The **`help()`** displays documentation about various Python objects including [ help(object) ``` -The object is passed to the `help()` function as parameter. -If an `object` is not provided, the interactive help utility will be started. +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 to 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()` will show its documentation page. +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 argument, the following output is returned: +Calling the `help()` function without an argument, the following output is returned: ```shell Welcome to Python 3's help utility! @@ -45,7 +44,7 @@ To get a list of available modules, keywords, symbols, or topics, type 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> +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: @@ -59,7 +58,7 @@ 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. @@ -68,8 +67,6 @@ print(...) flush: whether to forcibly flush the stream. ``` - - ## Codebyte Example The following example is runnable and shows how the `help()` function can be applied to different kinds of objects, including user-defined classes: