Published on

Declaring and Using Variables in Python

Authors

Generally speaking, a variable, or name, in a program refers to an object. A variable first needs to be introduced into the program using a special syntax. This is almost universally true in all C-style languages. Variables need to be declared before they can be used.

Python is an exception. Python is one of the few commonly-used languages in which a name can be used without first explicitly being declared.

It is very convenient. It is probably one of the reasons why many people prefer Python over other programming languages.

But there are pitfalls which even experienced Python programmers tend to overlook.

In most programming

introduction of a new name

use.

deletion

global, non-local