PEP 637 Added "how to teach" section (#1800)

This commit is contained in:
Stefano Borini 2021-02-06 18:18:02 +00:00 committed by GitHub
parent 9e81dc8092
commit cdfc88bebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -646,6 +646,33 @@ Finally, the following new slots must be added to the ``PyMappingMethods`` struc
These slots will have the appropriate signature to handle the dictionary object
containing the keywords.
"How to teach" recommendations
==============================
One request that occurred during feedback sessions was to detail a possible narrative
for teaching the feature, e.g. to students, data scientists, and similar audience.
This section addresses that need.
We will only describe the indexing from the perspective of use, not of
implementation, because it is the aspect that the above mentioned audience will
likely encounter. Only a subset of the users will have to implement their own
dunder functions, and can be considered advanced usage. A proper explanation could be:
The indexing operation is generally used to refer to a subset of a larger
dataset by means of an index. In the commonly seen cases, the index is made by
one or more numbers, strings, slices, etc.
Some types may allow indexing to occur not only with the index, but also with
named values. These named values are given between square brackets using the
same syntax used for function call keyword arguments. The meaning of the names
and their use is found in the documentation of the type, as it varies from one
type to another.
The teacher will now show some practical real world examples, explaining the
semantics of the feature in the shown library. At the time of writing these
examples do not exist, obviously, but the libraries most likely to implement
the feature are pandas and numpy, possibly as a method to refer to columns by
name.
Reference Implementation
========================