Consider these two statements, which serve the same purpose:
tel = {'sape': 4139, 'jack': 4098}
and
tel = dict([('sape', 4139), ('jack', 4098)])
Why use "dict()" at all?
I am sure there is a reason, i just want to know it.
Consider these two statements, which serve the same purpose:
tel = {'sape': 4139, 'jack': 4098}
and
tel = dict([('sape', 4139), ('jack', 4098)])
Why use "dict()" at all?
I am sure there is a reason, i just want to know it.
 
    
     
    
    The reason for the existence of dict(...) is that all classes need to have a constructor. Furthermore, it may be helpful if the constructor is able to take in data in a different format.
In your example use case, there is no benefit in using dict, because you can control the format the data is in. But consider if you have the data already as pairs in a list, the dict constructor may be useful. This can happen e.g. when reading lines from a file.
 
    
    map(dict,[[(1,2)]])
[{1: 2}]
map({},[[(1,2)]])
TypeError: 'dict' object is not callable
