Python Namespaces

The structures used to arrange the symbolic names allocated to objects in a Python programme are covered in this tutorial.

The relevance of objects in Python has been underlined in prior tutorials in this series. There are objects everywhere! Objects are the building blocks of everything your Python programme does.

An assignment statement gives an object a symbolic name that can be used to refer to it. The statement x ='foo' generates a symbolic name x for the string object 'foo.'Hundreds or thousands of such names will be created in a software of any complexity, each pointing to a specific object. How does Python keep track of all these names and make sure they don't collide?

A namespace in python is a set of currently specified symbolic names that includes information about the entity that each name refers to. A namespace can be thought of as a dictionary with the keys being the object names and the values being the objects themselves. Each key-value pair corresponds to a specific object.

Namespaces are a fantastic idea; let's do more of them!

Tim Peters' The Zen of Python

Built-In\sGlobal\sEnclosing\sLocal

These have varying lifespans. Python creates namespaces as needed and deletes them when they're no longer needed when a programme runs. Many namespaces will often exist at any given moment.

Comments

Popular posts from this blog

Unleashing Creativity: The Latest Frontier of Animation AI

Tanh Activation Function

Unveiling the Hidden Gems: Exploring Data Mining Functionality