Wool To Brave The Seasons - Learning Namespaces in Python

Wool To Brave The Seasons - Learning Namespaces in Python

"Wool to brave the seasons" is a line from the beyond stupendous and beautiful "invisible string" song by Taylor Swift. Software Engineering is my wool to brave the seasons.

Everything can be tough, but I have a passion and a love that keeps me going.

Everything can be tough, but I have something that I am meant to be doing.

Everything can be tough, but I know that I am meant to be doing this.

There are four main types of namespaces in Python

Four main types of namespaces exist in Python. 
  • The Built-In Namespace.
  • The Global Namespace
  • The Local Namespace
  • Enclosing Namespace
A close up of the head of a wind turbine surrounded by fields and some other wind turbines in the far background.
I am from Luxembourg - born and raised. We have such beautiful wind turbines back there.

I wanted to make it my mission to post as many of these beautiful wind turbines from Luxembourg as possible.

The Built-In Namespace

This is just like the generic built in functions that Python uses that we just take for granted. I assume it includes Errors and stuff as well. We don't have to import it - it's just there for us to use.

Things like len(), str(), int(), min(), max(), print(), and so on.

The Global Namespace

"There are potentially multiple namespaces in a single program" why arrrrrgh arrrrrrgh arrrrrrrgh arrrrrrgh please arrrrrgh.

Oh this just means that every module that you import has its own specific namespace.

The Local Namespace

"In Python, whenever the interpreter executes a function, it will generate a local namespace for that specific function.

This namespace only exists inside of the function and remains in existence until the function terminates."

Even function parameters can be included within the global namespace!!!!

If you call locals() in the global environment, then it will be exactly the same as if you called globals()!

Enclosing Namespace

Okay this means that when there is an outer function and an inner function nested inside of it, the outer function's local namespace becomes the inner function's enclosing namespace.

Comments

Popular posts from this blog

Hello World

Yosemite

Two Lines of Thought, Makes Me Wonder What I'm Missing