Python 3 latest code crumbs

Return a value from a Python function

Return a value from a Python function

Dec 14, 2021 by erik

In this example, we return a value from a Python function....

Your first program

Your first program

Dec 10, 2021 by erik

This is the interactive version of the example in the Python.land tutorial here....

Read YAML file with multiple documents with Python

Read YAML file with multiple documents with Python

Dec 10, 2021 by erik

PyYAML can read YAML files that contain multiple documents by using the yaml.safe_load_all() function. Note that the file needs to be opened as long as you're reading documents from the YAML, so you have to do your processing within the...

How to read YAML with Python and PyYAML

How to read YAML with Python and PyYAML

Dec 10, 2021 by erik

There are multiple Python packages that can parse YAML data. However, PyYAML is the most prevalent and also the most complete implementation for parsing YAML. PyYAML is not part of the standard Python library, meaning you need to install it...

Using docstrings to document your code

Using docstrings to document your code

Dec 8, 2021 by erik

A docstring is a string that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. You can read docstrings with the help() function....