Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Simple assignment and variables


We've seen a few examples of the essential Python assignment statement in previous chapters. The statement includes a variable, =, and an expression. Since a single object is an expression, we can write:

>>> pi = 3.14

This will create the floating-point literal 3.14 and assign this object to a variable named pi.

Variable names must follow the rules in section 2.3, Identifiers and Keywords, of the Python Language Reference. The reference manual uses the Unicode character class definitions provided in the unicodedata module.

Interesting background information on the problem of programming language identifiers is available in Unicode Standard Annex 31, Unicode Identifier and Pattern Syntax. This shows how the Python problem of how "what is an identifier?" fits into the larger context of other programming languages and the variety of natural languages used around the world.

In Python, identifiers have a small set of start characters; these are chosen to allow...