Page 1 of 2 Why Python? What makes this the super language of the 21st century? This extract from Programmer's Python: Everything is an Object explains what makes Python pythonic.
Programmer's Python Everything is an Object Second Edition
Is now available as a print book: Amazon

Contents
- Get Ready For The Python Difference
Extract 1: The Python Difference ***NEW!
- Variables, Objects and Attributes
- The Function Object
- Scope, Lifetime and Closure
Extract 1: Local and Global
- Advanced Functions
- Decorators
- Class, Methods and Constructors
Extract 1: Objects Become Classes
- Inside Class
- Meeting Metaclasses
Extract 1: Metaclass
- Advanced Attributes
- Custom Attribute Access
- Single Inheritance
- Multiple Inheritance
- Class and Type
- Type Annotation
- Operator Overloading
- Python In Visual Studio Code
Extracts from the first edition
<ASIN:1871962749>
<ASIN:1871962595>
<ASIN:1871962765>
Python is a remarkable language. It has more flexibility than most modern languages which makes it a very easy language to get started with. You don’t need to use type, you can ignore objects and functions and simply assign values to variables and write ifs and loops. Even quite sophisticated users of Python treat it as a “glue” language that simply orchestrates what a given set of objects do.

While it makes a really good scripting language, which is one of its big advantages, Python has features that make it a very capable language for lots of purposes. In addition, Python has a very strong internal logic, which often goes unappreciated and never to dig beneath the surface is a missed opportunity. Many programmers experienced in other object-oriented languages assume that they know Python because it has classes and objects, but this is far from being the whole story. Python really does do things differently, and while it might look like a traditional class-based language, it isn’t.
A Pythonesque Heritage
So what are Python’s origins? It started in 1990 as a hobby project by a single individual, Guido van Rossum. Many of the characteristics of Python and the overall direction of the project are down to decisions made by van Rossum who only recently relinquished the title of Benevolent Dictator For Life or BDFL for short, given to him by the Python community.
Python’s logo depicts two intertwined snake-like heads, which suggests van Rossum named his language project after a huge serpent. The name is actually a tribute to Monty Python’s Flying Circus, a classic satirical television series with a quirky sense of humor of which he was an enthusiastic fan at the time. If you’ve never encountered the TV show or its spin-off films you may by puzzled by some of the pythonesque references used in the Python ecosystem such as the IDE called IDLE in tribute to cast member Eric Idle. This book also has references to the Monty Python heritage. In its pages and code snippets you’ll find “spam”, “brian”, “grail” and others, and of course the reference in the book’s subtitle is to “And Now For Something Completely Different”, which was a well-known Monty Python catchphrase.
Python Today
Python has risen in prominence over recent years and is more popular now than when the first edition of this book was published. Why is it that so many more developers are choosing it? After all, Python may be a high quality language, but so is Java which has been displaced as the most-used language according to many rankings. Let’s take stock of the reasons for Python now being regarded as a phenomenon of modern programming.
Python is an open-source language that is now overseen by the Python Software Foundation, a non-profit corporation that owns the intellectual property rights of the language and aims to promote, protect, and advance it. You can use Python and distribute your program written in it without charge, even for commercial use. As an open-source project, the fact that Python has a large and active community has sometimes led to tensions, but going forward counts as one of the advantages of using it.
Python is largely platform-independent. You can download a version for Windows, Linux or Mac complete with a visual development environment, and the good news is that your Python application will often run on all these platforms, irrespective of where you developed it, another of its advantages.
Python is an interpreted object-oriented language that started out being simple and easy to use and has slowly collected a wide range of sophisticated features. This hasn’t always been an easy process as the language suffered a discontinuous change in 2008 with the release of Python 3.0, which wasn’t backward compatible with Python 2.0. Moving from Python 2, which was a very usable version of the language, to Python 3 which uses a more logical and better organized approach to classes and objects required a lot of work. A lot of man hours went into updating the language itself, but the effort required to make the hundreds of supporting Python 2 libraries work under Python 3 was a daunting task for their maintainers and indeed proved too much for some of them.
The transition from Python 2 to Python 3 was protracted to say the least and when the first edition of this book was published the end of life date for the 2.x line had been extended to 2020 to give the community more time to migrate. The fact that the final maintenance release of the line, Python 2.7.18, was finally released in April 2021, almost 4 months after the deadline, shows how tenaciously some people clung on to the older version. Over a year has passed since Python 2 finally departed the scene and the only times you’ll encounter it in this updated book is when there are interesting points of difference or aspects you need to be aware of to work with legacy code. The Python 3 line has seen regular updates, the most recent being version 3.10 and there are no plans for any more major upheavals to the language. The 3.x line has a steady and stable future with further evolution, but no more revolution – another advantage for its developers.
While Python has an important role as a scripting language there is a lot more to it. Python's excellent number crunching facilities have made it a number one choice for science and technology. In fact in many cases data scientists prefer its general-purpose approach to more directly data oriented languages like R. It is also dynamically typed. This is something that pleases many open minded programmers and infuriates the more strongly typed – you can guess which side of the argument I'm on. In short, Python is easy to get started with but it has a depth that you can make use of as you progress.
In chapter but not in this extract
- A Lightning Tour
- Getting Started
- Strings and Slices
- Data Structures
- Control Structures – Loops
- Space Matters
- Conditionals and Indenting
- Pattern Matching
- Everything Is An Object – References
- Functions
- An Object Of My Own
- Inheriting the Point
- Main and Modules
|