No, using an integer is a bad idea. This can happen in this case, if MiddleName always a string or None , but, as a rule, the implementation is free for integers, strings, tuples and other immutable values. CPython does this for small integers and constants of the above types. PyPy defines is by value for integers and several other types. Therefore, if MiddleName is 1, you will definitely see that your code does not take it into account.
Use object instead, each new object has a different identifier:
NotInFile = object()
Alternatively, for a better debug output, define your own class:
class NotInFileType(object):
If you are paranoid, you can make it a suitable single (ugly). If you need several such instances, you can rename the class to Sentiel or something else, make a representation of the instance variable and use multiple instances.
user395760
source share