Pragmatics of the standard is() function

Chris Angelico rosuav at gmail.com
Sat Nov 26 17:22:40 EST 2011


On Sun, Nov 27, 2011 at 8:20 AM, candide <candide at free.invalid> wrote:
> is() function makes comparaison of (abstract representation of) adresses of
> objects in memory. Comparing addresses of objects is a low level feature
> performed by low level langages such as C but seldom needed in high level
> languages like Python, isn'it ?

You also want 'is' when you're testing for a singleton used as a default value:

DEFAULT = object()

def foo(arg1,arg2,arg3=DEFAULT):
    if arg3 is DEFAULT: print("You gave me two args")


ChrisA



More information about the Python-list mailing list