Python Namespace Explained - Python Tutorial #9

Published: 05 March 2018
on channel: DMK Data
4,599
139

I've switched mostly to blogging and you can find it here: http://danielmuellerkomorowska.com/bl...

Here we are dealing with the concept of namespace in python. For now the namespace is the collection of all the names that we assign while programming and all the names that are built into python. When we assign a name to an object a new name is created in the namespace and the object is created in object-space. The name references the object so the name knows where the object lives in object-space. The object-space really is the memory of the computer.

There are two different types of objects in python: immutable and mutable objects. Immutable objects are unchangeable. Mutable objects are changeable. However, for both types of objects we can always change the object that the name references. We can change the reference by simply reassigning the same name. This makes is looks like we changed the object without changing the original object at its place in memory.

Mutable objects allow us to change them in-place. That is, we can change the object at its original location in memory. This opens us to some problems. For example when two names reference the same object and we change the object through one of those names, the object as seen through the other name is changed as well. This can cause some bugs that are fairly easy to catch but only when you understand how assignments and namespaces work.

Python:
https://www.python.org/

Outro Song:
Alright by Silent Partner is part of the YouTube Audio Library.


On this page of the site you can watch the video online Python Namespace Explained - Python Tutorial #9 with a duration of hours minute second in good quality, which was uploaded by the user DMK Data 05 March 2018, share the link with friends and acquaintances, this video has already been watched 4,599 times on youtube and it was liked by 139 viewers. Enjoy your viewing!