Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24353

Python Morsels: Understanding help() in Python

$
0
0

When using Python's help function, have you ever wondered what the various symbols (/, *, [, and ]) mean? Understanding those symbols will help you better understand how to use the functions and classes you're working with.

What do all the symbols mean in help output?

We'll cover what the * and / symbols below mean:

>>> help(sorted)Help on built-in function sorted in module builtins:sorted(iterable, /, *, key=None, reverse=False)    Return a new list containing all items from the iterable in ascending order.    A custom key function can be supplied to customize the sort order, and the    reverse flag can be set to request the result in descending order.

We'll also talk about the different formats that help output comes in. For example, note the square brackets in [x] below and note that there are two different styles noted for calling int:

>>> help(int)Help on class int in module builtins:class int(object) |  int([x]) -> integer |  int(x, base=10) -> integer

We'll start by giving a name to that line which indicates how a function, method, or class is called.

Multiple function signatures

A function signature notes the …

Read the full article: https://www.pythonmorsels.com/understanding-help/


Viewing all articles
Browse latest Browse all 24353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>