Python Namespace Explained - Python Tutorial #9

Pubblicato il: 05 marzo 2018
sul canale di: 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.


In questa pagina del sito puoi guardare il video online Python Namespace Explained - Python Tutorial #9 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato DMK Data 05 marzo 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 4,599 volte e gli è piaciuto 139 spettatori. Buona visione!