Chapter 4. COMPONENTS OF A PYTHON PROGRAM

There are three basic components to any language – the statement, the variable and the operator. When migrating from Perl to Python many of the operators and principles are actually the same: we can add two numbers together using +, compare two numbers using ==, and print out information to the screen using print.

However, there are also some differences – we can also concatenate (add) two strings together using the + operator, compare two objects – irrespective of type – using ==, and print is a statement, not a function.

In this chapter we're going to go through the basics of all three elements comparing the Perl versions to their Python equivalents where possible. We'll also look at some of the additional ...

Get Perl To Python Migration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.