Fix Python – ‘id’ is a bad variable name in Python


Asked By – brian buck

Why is it bad to name a variable id in Python?

Now we will see solution for issue: ‘id’ is a bad variable name in Python


id() is a fundamental built-in:

Help on built-in function id in module


    id(object) -> integer

    Return the identity of an object.  This is guaranteed to be unique among
    simultaneously existing objects.  (Hint: it's the object's memory

In general, using variable names that eclipse a keyword or built-in function in any language is a bad idea, even if it is allowed.

This question is answered By – Kevin Little

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0