2 Antworten
+ 5
Vinitha ,
yes it can be used as variable names, unfortunately there is no warning that this can create problems.
in general it is NOT recommended to use names from classes, build-in functions or other stuff and use them as variable names. this can lead to a unexpected behavior and creates errors that are difficult to identify.
so don't use: str, int, sum, ... as variable names
if you like these names, you can add a "_" at the end like sum_ = ...
happy coding!
+ 4
Basically, dict class has been written already during the python language development and is abstracted from the user ( meaning not very important to show the it's implementation to the user/programmer) . If you hate in-built python dict then you can even write your own dict data structure using any language that you want(using python itself).
For more detailed answer,
https://stackoverflow.com/questions/327311/how-are-pythons-built-in-dictionaries-implemented