Python Bites: Introduction

getting started

Lists and loops unwind,
Objects born with gentle ease,
Errors speak in kind.
- Haiku by ChatGPT 4o
These Bites are a linked series of web pages hosting presentations about the Python programming language. They are intended to ease entry into the craft of writing Python. Each Bite provides an introduction to, and discusses the ideas behind, some aspect of the language. A menu on this page (lower right - Pages) shows the things we will be covering in this sequence.

Why Python ?

Fig 1. Point Class Definition
Fig 2. Using Code
Fig 3. Output
Python is a relatively small and simple imperative language with effective standard library and many third-party libraries in many domains. It is interpreted and supports object oriented design with an uncluttered syntax. Its types are all dynamic, e.g., defined at run-time, so there is no static program analysis before execution. That means that most errors are found by exceptions thrown when the translator cannot correctly interpret a function.

Things you need to know:


  • All data types are references into data stored in a managed heap. That means that assignments assign handles, not data instances, so an assignment results in two handles pointing to the same data instance.
  • The Python standard library provides a deepcopy function that will make a new instance returned as an independent entity of the assignment source. Note that requires traversing and copying an object graph that could be quite large, and so may be an expensive operation.
  • Python has a relatively simple syntax that defines scope by source white-space indentation. A lot of its power comes from a substantial collection of standard and user-defined libraries.

Figures 1, 2, and 3 provide a sample of how Python code is structured. Figure 1. holds some of the code for a Point class definition. Figure 2 shows how using code creates and uses instances of the class, and Figure 3 displays the output when the code in Figure 2 runs.

References

reference comments
Python - Wikipedia Survey of Python through version 3
Python Home Page Download and access documentation
Python Documentation Tutorials, references for language and libraries, HowTos, Glossary