Notice these lines in multiprocessing package of standard libraries:
dict = dict list = list What's the point of rebinding some names already available on __builtins__ into the module scope? What is it trying to achieve? I searched for an explanation in the git blame, but this commit was large and there was no relevant comment.
self is only a reference to the current instance within the method. You can't change your instance by setting self .
In JavaScript, we can simply reassign the new value to the variable. When we change the value of a variable, we do not use var again. We simply use the = to give the variable a new value.
Variables in JavaScript do not have any type attached. Once you assign a specific literal type to a variable, you can later reassign the variable to host any other type, without type errors or any issue. This is why JavaScript is sometimes referred to as “untyped”. A variable must be declared before you can use it.
Bottom line: you can't have two things simultaneously with the same name, be it a function, an integer, or any other object in Python. Just use a different name.
This code occurs in multiprocessing.dummy, a "fake" version of multiprocessing that implements the functionality with threads. If you look down a few lines, you'll see
def Manager(): return sys.modules[__name__] multiprocessing.dummy implements Manager as a function that just returns the multiprocessing.dummy module itself, so the multiprocessing.dummy module object has to provide the API of a multiprocessing Manager object. The lines
dict = dict list = list copy the bindings for the dict and list names from the builtins namespace into the module's namespace, so you can do
m = multiprocessing.dummy.Manager() d = m.dict() as if you had a real multiprocessing.Manager().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With