]> granicus.if.org Git - python/commitdiff
Replace boolean test with is None.
authorRaymond Hettinger <python@rcn.com>
Sat, 1 Jun 2002 16:07:16 +0000 (16:07 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 1 Jun 2002 16:07:16 +0000 (16:07 +0000)
Lib/mhlib.py
Lib/netrc.py
Lib/poplib.py
Lib/pprint.py
Lib/profile.py
Lib/pstats.py
Lib/py_compile.py

index d4869c62368df065b1302fc23f2e210efc40c07a..912f0015b7eea987b4d31f9f092d27865c27941d 100644 (file)
@@ -98,9 +98,9 @@ class MH:
 
     def __init__(self, path = None, profile = None):
         """Constructor."""
-        if not profile: profile = MH_PROFILE
+        if profile is None: profile = MH_PROFILE
         self.profile = os.path.expanduser(profile)
-        if not path: path = self.getprofile('Path')
+        if path is None: path = self.getprofile('Path')
         if not path: path = PATH
         if not os.path.isabs(path) and path[0] != '~':
             path = os.path.join('~', path)
@@ -665,7 +665,7 @@ class Message(mimetools.Message):
         """Constructor."""
         self.folder = f
         self.number = n
-        if not fp:
+        if fp is None:
             path = f.getmessagefilename(n)
             fp = open(path, 'r')
         mimetools.Message.__init__(self, fp)
@@ -679,7 +679,7 @@ class Message(mimetools.Message):
         argument is specified, it is used as a filter predicate to
         decide which headers to return (its argument is the header
         name converted to lower case)."""
-        if not pred:
+        if pred is None:
             return ''.join(self.headers)
         headers = []
         hit = 0
@@ -791,7 +791,7 @@ class IntSet:
         self.pairs = []
         self.sep = sep
         self.rng = rng
-        if data: self.fromstring(data)
+        if data is not None: self.fromstring(data)
 
     def reset(self):
         self.pairs = []
index 9ce7efb060b1c71ef412a1966f71970631239c8b..316a66c8867db8f5a90999ec4edb09c6d02e7fd7 100644 (file)
@@ -21,7 +21,7 @@ class NetrcParseError(Exception):
 
 class netrc:
     def __init__(self, file=None):
-        if not file:
+        if file is None:
             try:
                 file = os.path.join(os.environ['HOME'], ".netrc")
             except KeyError:
index 052504302e7f4bdf5b4e7e749b1a87a32841e6e5..0b22b2e4efe3ad52c224b99767a532e8a37ca957 100644 (file)
@@ -220,7 +220,7 @@ class POP3:
         Result when a message number argument is given is a
         single response: the "scan listing" for that message.
         """
-        if which:
+        if which is not None:
             return self._shortcmd('LIST %s' % which)
         return self._longcmd('LIST')
 
@@ -313,7 +313,7 @@ class POP3:
         in the form 'response mesgnum uid', otherwise result is
         the list ['response', ['mesgnum uid', ...], octets]
         """
-        if which:
+        if which is not None:
             return self._shortcmd('UIDL %s' % which)
         return self._longcmd('UIDL')
 
index 1c1159315f432e5a4cfe1fef9ec0b5c512e186bb..523572ba8952e1f6fa827c0b83bacba288d46b59 100644 (file)
@@ -101,7 +101,7 @@ class PrettyPrinter:
         self.__depth = depth
         self.__indent_per_level = indent
         self.__width = width
-        if stream:
+        if stream is not None:
             self.__stream = stream
         else:
             self.__stream = sys.stdout
index fa3527f03f785b6632d13fd2537a1a9f7733def5..c1001f9005f10003def9a786dd003f7cc623ca72 100755 (executable)
@@ -150,7 +150,7 @@ class Profile:
             bias = self.bias
         self.bias = bias     # Materialize in local dict for lookup speed.
 
-        if not timer:
+        if timer is None:
             if os.name == 'mac':
                 self.timer = MacOS.GetTicks
                 self.dispatcher = self.trace_dispatch_mac
index 126d0beec6dbd4a384e1feb3cde8da4e78c5baef..c5d8c3899f6b0ca670809dc6bfda1c94d14a8ee1 100644 (file)
@@ -506,7 +506,7 @@ if __name__ == '__main__':
         def __init__(self, profile=None):
             cmd.Cmd.__init__(self)
             self.prompt = "% "
-            if profile:
+            if profile is not None:
                 self.stats = Stats(profile)
             else:
                 self.stats = None
index afeaae12c6f1f56801401cdc98d40997a37476c1..ce67584991f3fe5081bc0247c2302a30b15f879c 100644 (file)
@@ -67,7 +67,7 @@ def compile(file, cfile=None, dfile=None):
             sys.stderr.write(line.replace('File "<string>"',
                                             'File "%s"' % (dfile or file)))
         return
-    if not cfile:
+    if cfile is None:
         cfile = file + (__debug__ and 'c' or 'o')
     fc = open(cfile, 'wb')
     fc.write('\0\0\0\0')