Python Namespace Explained - Python Tutorial #9

Veröffentlicht am: 05 März 2018
auf dem Kanal: 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.


Auf dieser Seite können Sie das Online-Video Python Namespace Explained - Python Tutorial #9 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer DMK Data 05 März 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 4,599 Mal angesehen und es wurde von 139 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!