0

i am confused with the usage of == and is.

default_netrc = file is None
if file is None:
    try:
        file = os.path.join(os.environ['HOME'], ".netrc")
    except KeyError:
        raise IOError("Could not find .netrc: $HOME is not set")

Here is the code snap.

Is this line default_netrc = file is None is equal default_netrc = file == None?

when compare with None, should we use is or ==?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
BlackMamba
  • 10,054
  • 7
  • 44
  • 67

1 Answers1

0

a is b returns id(a)==id(b), which is true if the labels point to the same object. a==b returns true if the (potentially different) objects pointed to by a and b are equivalent in a way defined by the objects being compared.

Pedro
  • 409
  • 2
  • 7