What Is a Python Package?

A Python package is simply a directory, usually containing Python modules (source files with the .py extension). It frequently will include a special marker file, __init__.py. Packages can easily be created and used locally, and published packages can be installed using pip. Learning to install public packages and create packages locally is not difficult, though … Read more

Is Python Slow? Separating the Myths from the Facts

Winning the foot race.

Yes, it’s true that Python is slower at runtime than some other languages, but it’s fast enough for the tasks for which it is commonly used. Yes, it’s true that Python is slower at runtime than some other languages, but it’s fast enough for the tasks for which it is commonly used. For the most common tasks, the popular libraries use well-optimized C code — but you don’t need to know C to use them. We separate the facts from the myths.

Exploring Python Objects with the dir and type functions

Two of my favorite functions for interactively exploring Python objects are dir and type. Calling the dir function with no attributes returns information about what’s defined in the current module — either by default when you start the python interpreter, or because you’ve done imports, defined variables and functions and classes, etc. Calling dir and … Read more