Python 3 latest code crumbs

Python class example

Python class example

Feb 12, 2022 by erik

This is an example of a Python class. This class represents a car. It could be part of a game, for example, in which you have multiple cars running around. This example is part of the [Python objects and classes...

Python Hello World

Python Hello World

Feb 11, 2022 by erik

This is a typical Hello World example in Python. It's part of the free and complete Python Tutorial for beginners at python.land....

Runnable Python module

Runnable Python module

Feb 4, 2022 by erik

When we import a module, its name (stored in the variable __name__) is equal to the module name. When a script is executed, its name is always set to the__main__ string. Hence, if we check for this name with `if...

Python modules

Python modules

Jan 25, 2022 by erik

You can import a Python module by using the import keyword. Module imports are often placed at the top of a script, but they don't have to be. E.g., sometimes you want to dynamically decide if you need to import...

Python Dictionary View Objects

Python Dictionary View Objects

Jan 21, 2022 by erik

Some built-in Python dictionary methods return a view object, offering a window on your dictionary's keys and values. There's an important concept you need to understand: values in a view object change as the content of the dictionary changes. In...

Default values and named parameters

Default values and named parameters

Jan 16, 2022 by erik

A compelling Python feature is the ability to provide default values for the parameters. Because our parameters have a default value, you don't have to fill them in. If you don't, the default is used. If you do, you override...