]> granicus.if.org Git - python/commitdiff
Update the code to better reflect recommended style:
authorFred Drake <fdrake@acm.org>
Tue, 12 Dec 2000 23:20:45 +0000 (23:20 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 12 Dec 2000 23:20:45 +0000 (23:20 +0000)
Use != instead of <> since <> is documented as "obsolescent".
Use "is" and "is not" when comparing with None or type objects.

36 files changed:
Lib/Cookie.py
Lib/binhex.py
Lib/calendar.py
Lib/cmd.py
Lib/commands.py
Lib/dircache.py
Lib/dospath.py
Lib/filecmp.py
Lib/ftplib.py
Lib/imputil.py
Lib/linecache.py
Lib/macpath.py
Lib/macurl2path.py
Lib/mailbox.py
Lib/mailcap.py
Lib/mhlib.py
Lib/mimetools.py
Lib/multifile.py
Lib/netrc.py
Lib/nntplib.py
Lib/ntpath.py
Lib/pdb.py
Lib/pipes.py
Lib/posixpath.py
Lib/quopri.py
Lib/regsub.py
Lib/sgmllib.py
Lib/smtplib.py
Lib/sndhdr.py
Lib/statcache.py
Lib/sunaudio.py
Lib/toaiff.py
Lib/tzparse.py
Lib/uu.py
Lib/xdrlib.py
Lib/xmllib.py

index 67259af5f6945fc30077818593e4eb07999b9d6c..223e71502a449f54f02ac9bac99f72776b1bf2b1 100644 (file)
@@ -489,7 +489,7 @@ class Morsel(UserDict):
         RA("%s=%s;" % (self.key, self.coded_value))
 
         # Now add any defined attributes
-        if attrs == None:
+        if attrs is None:
             attrs = self._reserved_keys
         for K,V in self.items():
             if V == "": continue
index 08922031e1cddbf249250d6fb6d1a295133ec92e..fe695ac5a75154ad98ba0cbe14cc6abb55241fe7 100644 (file)
@@ -189,7 +189,7 @@ class BinHex:
         hqxer = _Hqxcoderengine(ofp)
         self.ofp = _Rlecoderengine(hqxer)
         self.crc = 0
-        if finfo == None:
+        if finfo is None:
             finfo = FInfo()
         self.dlen = dlen
         self.rlen = rlen
@@ -228,7 +228,7 @@ class BinHex:
         self._write(data)
 
     def close_data(self):
-        if self.dlen <> 0:
+        if self.dlen != 0:
             raise Error, 'Incorrect data size, diff='+`self.rlen`
         self._writecrc()
         self.state = _DID_DATA
@@ -246,7 +246,7 @@ class BinHex:
             self.close_data()
         if self.state != _DID_DATA:
             raise Error, 'Close at the wrong time'
-        if self.rlen <> 0:
+        if self.rlen != 0:
             raise Error, \
                   "Incorrect resource-datasize, diff="+`self.rlen`
         self._writecrc()
index 41bb191478db9ae93039e35407b34b62a81d6755..01c21947a9def954c7c1578307b62a2f6e2b43cb 100644 (file)
@@ -50,7 +50,7 @@ def setfirstweekday(weekday):
 
 def isleap(year):
     """Return 1 for leap years, 0 for non-leap years."""
-    return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
+    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
 
 def leapdays(y1, y2):
     """Return number of leap years in range [y1, y2).
index 41b229325a67da10219bef4251e90e1b46296cc4..7671573953257c047be8f1bc28c7ed44a6d716f3 100644 (file)
@@ -57,7 +57,7 @@ class Cmd:
 
     def cmdloop(self, intro=None):
         self.preloop()
-        if intro != None:
+        if intro is not None:
             self.intro = intro
         if self.intro:
             print self.intro
index 12acc364087e0f3f35f991f4678c408e713cbcab..99387b1053eb201282bbe96782f50dc9faa3f116 100644 (file)
@@ -51,7 +51,7 @@ def getstatusoutput(cmd):
     pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
     text = pipe.read()
     sts = pipe.close()
-    if sts == None: sts = 0
+    if sts is None: sts = 0
     if text[-1:] == '\n': text = text[:-1]
     return sts, text
 
index a35e16d1bc6ad5366e9c84c04fb47c1f0ca98f3c..08b127a1afbc0e66602e45c288a2083fb4496b14 100644 (file)
@@ -19,7 +19,7 @@ def listdir(path):
         mtime = os.stat(path)[8]
     except os.error:
         return []
-    if mtime <> cached_mtime:
+    if mtime != cached_mtime:
         try:
             list = os.listdir(path)
         except os.error:
index f44d499e53f9bd11f79d3e0f6bb2052ffe754ad0..17db624e835f9bc980d179d07979bb3e5aca318d 100644 (file)
@@ -108,7 +108,7 @@ def commonprefix(m):
     prefix = m[0]
     for item in m:
         for i in range(len(prefix)):
-            if prefix[:i+1] <> item[:i+1]:
+            if prefix[:i+1] != item[:i+1]:
                 prefix = prefix[:i]
                 if i == 0: return ''
                 break
@@ -210,7 +210,7 @@ def expanduser(path):
     (A function should also be defined to do full *sh-style environment
     variable expansion.)"""
 
-    if path[:1] <> '~':
+    if path[:1] != '~':
         return path
     i, n = 1, len(path)
     while i < n and path[i] not in '/\\':
@@ -303,7 +303,7 @@ def normpath(path):
                       comps[i-1] not in ('', '..'):
             del comps[i-1:i+1]
             i = i - 1
-        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
+        elif comps[i] == '' and i > 0 and comps[i-1] != '':
             del comps[i]
         elif '.' in comps[i]:
             comp = comps[i].split('.')
index e5024a493a586e3c271eddeaf770ee7d53ce3b64..eb98a71cc4faea9e9bf5a34c92b47901658c5c48 100644 (file)
@@ -199,7 +199,7 @@ class dircmp:
             if ok:
                 a_type = stat.S_IFMT(a_stat[stat.ST_MODE])
                 b_type = stat.S_IFMT(b_stat[stat.ST_MODE])
-                if a_type <> b_type:
+                if a_type != b_type:
                     self.common_funny.append(x)
                 elif stat.S_ISDIR(a_type):
                     self.common_dirs.append(x)
@@ -317,7 +317,8 @@ def demo():
     import sys
     import getopt
     options, args = getopt.getopt(sys.argv[1:], 'r')
-    if len(args) <> 2: raise getopt.error, 'need exactly two args'
+    if len(args) != 2:
+        raise getopt.error, 'need exactly two args'
     dd = dircmp(args[0], args[1])
     if ('-r', '') in options:
         dd.report_full_closure()
index 429e834a934a10f0e7154dea6cb2b4a111b30528..df28200394cf1e86e9d627ac7729756bab54b827 100644 (file)
@@ -185,7 +185,7 @@ class FTP:
                                nextline = self.getline()
                                line = line + ('\n' + nextline)
                                if nextline[:3] == code and \
-                                       nextline[3:4] <> '-':
+                                       nextline[3:4] != '-':
                                        break
                return line
 
@@ -207,7 +207,7 @@ class FTP:
        def voidresp(self):
                """Expect a response beginning with '2'."""
                resp = self.getresp()
-               if resp[0] <> '2':
+               if resp[0] != '2':
                        raise error_reply, resp
                return resp
 
@@ -277,14 +277,14 @@ class FTP:
                        if rest is not None:
                                self.sendcmd("REST %s" % rest)
                        resp = self.sendcmd(cmd)
-                       if resp[0] <> '1':
+                       if resp[0] != '1':
                                raise error_reply, resp
                else:
                        sock = self.makeport()
                        if rest is not None:
                                self.sendcmd("REST %s" % rest)
                        resp = self.sendcmd(cmd)
-                       if resp[0] <> '1':
+                       if resp[0] != '1':
                                raise error_reply, resp
                        conn, sockaddr = sock.accept()
                if resp[:3] == '150':
@@ -318,7 +318,7 @@ class FTP:
                resp = self.sendcmd('USER ' + user)
                if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
                if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct)
-               if resp[0] <> '2':
+               if resp[0] != '2':
                        raise error_reply, resp
                return resp
 
@@ -384,7 +384,7 @@ class FTP:
                while 1:
                        buf = fp.readline()
                        if not buf: break
-                       if buf[-2:] <> CRLF:
+                       if buf[-2:] != CRLF:
                                if buf[-1] in CRLF: buf = buf[:-1]
                                buf = buf + CRLF
                        conn.send(buf)
@@ -423,7 +423,7 @@ class FTP:
        def rename(self, fromname, toname):
                '''Rename a file.'''
                resp = self.sendcmd('RNFR ' + fromname)
-               if resp[0] <> '3':
+               if resp[0] != '3':
                        raise error_reply, resp
                return self.voidcmd('RNTO ' + toname)
 
@@ -508,7 +508,7 @@ def parse227(resp):
        Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
        Return ('host.addr.as.numbers', port#) tuple.'''
 
-       if resp[:3] <> '227':
+       if resp[:3] != '227':
                raise error_reply, resp
        left = string.find(resp, '(')
        if left < 0: raise error_proto, resp
@@ -516,7 +516,7 @@ def parse227(resp):
        if right < 0:
                raise error_proto, resp # should contain '(h1,h2,h3,h4,p1,p2)'
        numbers = string.split(resp[left+1:right], ',')
-       if len(numbers) <> 6:
+       if len(numbers) != 6:
                raise error_proto, resp
        host = string.join(numbers[:4], '.')
        port = (string.atoi(numbers[4]) << 8) + string.atoi(numbers[5])
@@ -528,9 +528,9 @@ def parse257(resp):
        This is a response to a MKD or PWD request: a directory name.
        Returns the directoryname in the 257 reply.'''
 
-       if resp[:3] <> '257':
+       if resp[:3] != '257':
                raise error_reply, resp
-       if resp[3:5] <> ' "':
+       if resp[3:5] != ' "':
                return '' # Not compliant to RFC 959, but UNIX ftpd does this
        dirname = ''
        i = 5
@@ -539,7 +539,7 @@ def parse257(resp):
                c = resp[i]
                i = i+1
                if c == '"':
-                       if i >= n or resp[i] <> '"':
+                       if i >= n or resp[i] != '"':
                                break
                        i = i+1
                dirname = dirname + c
index d442d9fa2281e9f55f47639b4afe104b9f07c1e5..0dd7b51eb1a1120416d7c1b8eb996352fd542bcf 100644 (file)
@@ -434,7 +434,7 @@ def _os_bootstrap():
             path = s
             if ':' not in a:
                 a = ':' + a
-            if a[-1:] <> ':':
+            if a[-1:] != ':':
                 a = a + ':'
             return a + b
     else:
@@ -643,7 +643,7 @@ def _test_revamp():
 # from Guido:
 #   need to change sys.* references for rexec environs
 #   need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy
-#   watch out for sys.modules[...] == None
+#   watch out for sys.modules[...] is None
 #   flag to force absolute imports? (speeds _determine_import_context and
 #       checking for a relative module)
 #   insert names of archives into sys.path  (see quote below)
index bca40b291cda8d19623d69c78efb6d3ea7ef8aee..c39f8db5954d0d022119f9edc0a7dc9f3d57b17a 100644 (file)
@@ -50,7 +50,7 @@ def checkcache():
         except os.error:
             del cache[filename]
             continue
-        if size <> stat[ST_SIZE] or mtime <> stat[ST_MTIME]:
+        if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]:
             del cache[filename]
 
 
index 12eec0c97ea5c81db2c10116a4cd89c316e4b68b..bf2660f4f1dfe8944769f48d98c1bdf33213fb46 100644 (file)
@@ -17,7 +17,7 @@ def isabs(s):
     Anything else is absolute (the string up to the first colon is the
     volume name)."""
 
-    return ':' in s and s[0] <> ':'
+    return ':' in s and s[0] != ':'
 
 
 def join(s, *p):
@@ -30,7 +30,7 @@ def join(s, *p):
             t = t[1:]
         if ':' not in path:
             path = ':' + path
-        if path[-1:] <> ':':
+        if path[-1:] != ':':
             path = path + ':'
         path = path + t
     return path
@@ -151,7 +151,7 @@ def commonprefix(m):
     prefix = m[0]
     for item in m:
         for i in range(len(prefix)):
-            if prefix[:i+1] <> item[:i+1]:
+            if prefix[:i+1] != item[:i+1]:
                 prefix = prefix[:i]
                 if i == 0: return ''
                 break
index c971edaa22dad13a1ffe4b57cff15255334ef45a..9daeae4a65f4b2a2e6e0a734c9f4ca8b56e8b2ad 100644 (file)
@@ -12,7 +12,7 @@ def url2pathname(pathname):
     # XXXX The .. handling should be fixed...
     #
     tp = urllib.splittype(pathname)[0]
-    if tp and tp <> 'file':
+    if tp and tp != 'file':
         raise RuntimeError, 'Cannot convert non-local URL to pathname'
     # Turn starting /// into /, an empty hostname means current host
     if pathname[:3] == '///':
@@ -29,7 +29,7 @@ def url2pathname(pathname):
                                   components[i-1] not in ('', '..'):
             del components[i-1:i+1]
             i = i-1
-        elif components[i] == '' and i > 0 and components[i-1] <> '':
+        elif components[i] == '' and i > 0 and components[i-1] != '':
             del components[i]
         else:
             i = i+1
index c92e1452e4848ee3cab4aba953a5fa24367372e7..53b2c19f61375b168a90691fdd2c419cf33a285d 100755 (executable)
@@ -30,7 +30,7 @@ class _Mailbox:
             start = self.fp.tell()
             self._search_end()
             self.seekp = stop = self.fp.tell()
-            if start <> stop:
+            if start != stop:
                 break
         return rfc822.Message(_Subfile(self.fp, start, stop))
 
index 636f2dd2444f80f76e7aab8377c177b468d5858a..9756594cb8a6be6003a791bbb40d270593f683fe 100644 (file)
@@ -173,7 +173,7 @@ def subst(field, MIMEtype, filename, plist=[]):
     i, n = 0, len(field)
     while i < n:
         c = field[i]; i = i+1
-        if c <> '%':
+        if c != '%':
             if c == '\\':
                 c = field[i:i+1]; i = i+1
             res = res + c
@@ -187,7 +187,7 @@ def subst(field, MIMEtype, filename, plist=[]):
                 res = res + MIMEtype
             elif c == '{':
                 start = i
-                while i < n and field[i] <> '}':
+                while i < n and field[i] != '}':
                     i = i+1
                 name = field[start:i]
                 i = i+1
index df538f274e8a096de626d455ecbb297449eceae0..f5ece05e342ca449b187415b75a8801c92174137 100644 (file)
@@ -305,7 +305,7 @@ class Folder:
             line = f.readline()
             if not line: break
             fields = string.splitfields(line, ':')
-            if len(fields) <> 2:
+            if len(fields) != 2:
                 self.error('bad sequence in %s: %s' %
                           (fullname, string.strip(line)))
             key = string.strip(fields[0])
index da955af05dab883a908194ffba777443a187c54c..abdfa62fbb7c34e673440f75fa51dc02afa8b445 100644 (file)
@@ -22,7 +22,7 @@ class Message(rfc822.Message):
 
        def parsetype(self):
                str = self.typeheader
-               if str == None:
+               if str is None:
                        str = 'text/plain'
                if ';' in str:
                        i = string.index(str, ';')
@@ -75,7 +75,7 @@ class Message(rfc822.Message):
                return result
 
        def getencoding(self):
-               if self.encodingheader == None:
+               if self.encodingheader is None:
                        return '7bit'
                return string.lower(self.encodingheader)
 
@@ -109,7 +109,7 @@ def choose_boundary():
        global _prefix
        import time
        import random
-       if _prefix == None:
+       if _prefix is None:
                import socket
                import os
                hostid = socket.gethostbyname(socket.gethostname())
index e43d331c57144a43851eaff6c261672bdc75d441..54de947798be005d89e167dbca7ba81dcdd83c9e 100644 (file)
@@ -155,7 +155,7 @@ class MultiFile:
                                self.lastpos = abslastpos - self.start
 
        def is_data(self, line):
-               return line[:2] <> '--'
+               return line[:2] != '--'
 
        def section_divider(self, str):
                return "--" + str
index c46ba7319099024edd1a259ccf84fc93ceb136df..e3374b062afa5eab3f4b8dcd22a0f5d5a506c557 100644 (file)
@@ -17,7 +17,7 @@ class netrc:
         while 1:
             # Look for a machine, default, or macdef top-level keyword
             toplevel = tt = lexer.get_token()
-            if tt == '' or tt == None:
+            if not tt:
                 break
             elif tt == 'machine':
                 entryname = lexer.get_token()
index 7a90543db3fb7bc83a4d7fb65a4f1b654ab3b5df..526677a95cf09bfa3ab909a84485addd86fe73ea 100644 (file)
@@ -258,7 +258,7 @@ class NNTP:
                - name: the group name"""
 
                resp = self.shortcmd('GROUP ' + name)
-               if resp[:3] <> '211':
+               if resp[:3] != '211':
                        raise NNTPReplyError(resp)
                words = string.split(resp)
                count = first = last = 0
@@ -282,7 +282,7 @@ class NNTP:
 
        def statparse(self, resp):
                """Internal: parse the response of a STAT, NEXT or LAST command."""
-               if resp[:2] <> '22':
+               if resp[:2] != '22':
                        raise NNTPReplyError(resp)
                words = string.split(resp)
                nr = 0
@@ -429,7 +429,7 @@ class NNTP:
                path: directory path to article"""
 
                resp = self.shortcmd("XPATH " + id)
-               if resp[:3] <> '223':
+               if resp[:3] != '223':
                        raise NNTPReplyError(resp)
                try:
                        [resp_num, path] = string.split(resp)
@@ -447,7 +447,7 @@ class NNTP:
                time: Time suitable for newnews/newgroups commands etc."""
 
                resp = self.shortcmd("DATE")
-               if resp[:3] <> '111':
+               if resp[:3] != '111':
                        raise NNTPReplyError(resp)
                elem = string.split(resp)
                if len(elem) != 2:
@@ -467,7 +467,7 @@ class NNTP:
 
                resp = self.shortcmd('POST')
                # Raises error_??? if posting is not allowed
-               if resp[0] <> '3':
+               if resp[0] != '3':
                        raise NNTPReplyError(resp)
                while 1:
                        line = f.readline()
@@ -491,7 +491,7 @@ class NNTP:
 
                resp = self.shortcmd('IHAVE ' + id)
                # Raises error_??? if the server already has it
-               if resp[0] <> '3':
+               if resp[0] != '3':
                        raise NNTPReplyError(resp)
                while 1:
                        line = f.readline()
index efcba6df923cd2ce96a6f8c5f9952f5d2f19adc7..c1f4df7d4c82aed3ad9cd189a4ce4c7b8ace02a6 100644 (file)
@@ -160,7 +160,7 @@ def commonprefix(m):
     prefix = m[0]
     for item in m:
         for i in range(len(prefix)):
-            if prefix[:i+1] <> item[:i+1]:
+            if prefix[:i+1] != item[:i+1]:
                 prefix = prefix[:i]
                 if i == 0: return ''
                 break
@@ -283,7 +283,7 @@ def expanduser(path):
     """Expand ~ and ~user constructs.
 
     If user or $HOME is unknown, do nothing."""
-    if path[:1] <> '~':
+    if path[:1] != '~':
         return path
     i, n = 1, len(path)
     while i < n and path[i] not in '/\\':
@@ -387,7 +387,7 @@ def normpath(path):
         elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
             del comps[i-1:i+1]
             i = i - 1
-        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
+        elif comps[i] == '' and i > 0 and comps[i-1] != '':
             del comps[i]
         else:
             i = i + 1
index db4a2cde6114f53be7163363e493297f7dfd0615..f4a0c89f4c19d652eafadefe83fb7cd81c1445d2 100755 (executable)
@@ -553,7 +553,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
                        first = max(1, self.curframe.f_lineno - 5)
                else:
                        first = self.lineno + 1
-               if last == None:
+               if last is None:
                        last = first + 10
                filename = self.curframe.f_code.co_filename
                breaklist = self.get_file_breaks(filename)
@@ -895,7 +895,8 @@ def set_trace():
 def post_mortem(t):
        p = Pdb()
        p.reset()
-       while t.tb_next <> None: t = t.tb_next
+       while t.tb_next is not None:
+               t = t.tb_next
        p.interaction(t.tb_frame, t)
 
 def pm():
index 4057fac07772fe7f35413f05460babd1662bf8fd..3aa1bf1f221f8b5c1d7ed838812a0431e43d87eb 100644 (file)
@@ -110,7 +110,7 @@ class Template:
 
        def append(self, cmd, kind):
                """t.append(cmd, kind) adds a new step at the end."""
-               if type(cmd) <> type(''):
+               if type(cmd) is not type(''):
                        raise TypeError, \
                              'Template.append: cmd must be a string'
                if kind not in stepkinds:
@@ -119,7 +119,7 @@ class Template:
                if kind == SOURCE:
                        raise ValueError, \
                              'Template.append: SOURCE can only be prepended'
-               if self.steps <> [] and self.steps[-1][1] == SINK:
+               if self.steps and self.steps[-1][1] == SINK:
                        raise ValueError, \
                              'Template.append: already ends with SINK'
                if kind[0] == 'f' and not re.search('\$IN\b', cmd):
@@ -132,7 +132,7 @@ class Template:
 
        def prepend(self, cmd, kind):
                """t.prepend(cmd, kind) adds a new step at the front."""
-               if type(cmd) <> type(''):
+               if type(cmd) is not type(''):
                        raise TypeError, \
                              'Template.prepend: cmd must be a string'
                if kind not in stepkinds:
@@ -141,7 +141,7 @@ class Template:
                if kind == SINK:
                        raise ValueError, \
                              'Template.prepend: SINK can only be appended'
-               if self.steps <> [] and self.steps[0][1] == SOURCE:
+               if self.steps and self.steps[0][1] == SOURCE:
                        raise ValueError, \
                              'Template.prepend: already begins with SOURCE'
                if kind[0] == 'f' and not re.search('\$IN\b', cmd):
@@ -165,7 +165,7 @@ class Template:
        def open_r(self, file):
                """t.open_r(file) and t.open_w(file) implement
                t.open(file, 'r') and t.open(file, 'w') respectively."""
-               if self.steps == []:
+               if not self.steps:
                        return open(file, 'r')
                if self.steps[-1][1] == SINK:
                        raise ValueError, \
@@ -174,7 +174,7 @@ class Template:
                return os.popen(cmd, 'r')
 
        def open_w(self, file):
-               if self.steps == []:
+               if not self.steps:
                        return open(file, 'w')
                if self.steps[0][1] == SOURCE:
                        raise ValueError, \
@@ -203,7 +203,7 @@ def makepipeline(infile, steps, outfile):
        #
        # Make sure there is at least one step
        #
-       if list == []:
+       if not list:
                list.append(['', 'cat', '--', ''])
        #
        # Take care of the input and output ends
index 28266048211bed4cc2f2e07292c02b353fd2d033..32850b4ba74589cc9aec769751ebeb9b9934697c 100644 (file)
@@ -59,7 +59,7 @@ def split(p):
     everything after the final slash.  Either part may be empty."""
     i = p.rfind('/') + 1
     head, tail = p[:i], p[i:]
-    if head and head <> '/'*len(head):
+    if head and head != '/'*len(head):
         while head[-1] == '/':
             head = head[:-1]
     return head, tail
@@ -120,7 +120,7 @@ def commonprefix(m):
     prefix = m[0]
     for item in m:
         for i in range(len(prefix)):
-            if prefix[:i+1] <> item[:i+1]:
+            if prefix[:i+1] != item[:i+1]:
                 prefix = prefix[:i]
                 if i == 0: return ''
                 break
@@ -281,10 +281,10 @@ def walk(top, func, arg):
 def expanduser(path):
     """Expand ~ and ~user constructions.  If user or $HOME is unknown, 
     do nothing."""
-    if path[:1] <> '~':
+    if path[:1] != '~':
         return path
     i, n = 1, len(path)
-    while i < n and path[i] <> '/':
+    while i < n and path[i] != '/':
         i = i + 1
     if i == 1:
         if not os.environ.has_key('HOME'):
index b449792e402a2ec41013831fd7b984933bc207c5..80fc6f911fe2b9cbce8733229451fb1b857700c6 100755 (executable)
@@ -69,7 +69,7 @@ def decode(input, output):
             partial = 1
         while i < n:
             c = line[i]
-            if c <> ESCAPE:
+            if c != ESCAPE:
                 new = new + c; i = i+1
             elif i+1 == n and not partial:
                 partial = 1; break
index 8e341bb758ea3f3ac50a800f380bf1054778e352..dc95028b34494af8adaa2d823c00b17848661a48 100644 (file)
@@ -124,7 +124,7 @@ def capwords(str, pat='[^a-zA-Z0-9_]+'):
 cache = {}
 
 def compile(pat):
-       if type(pat) <> type(''):
+       if type(pat) != type(''):
                return pat              # Assume it is a compiled regex
        key = (pat, regex.get_syntax())
        if cache.has_key(key):
@@ -153,7 +153,7 @@ def expand(repl, regs, str):
        ord0 = ord('0')
        while i < len(repl):
                c = repl[i]; i = i+1
-               if c <> '\\' or i >= len(repl):
+               if c != '\\' or i >= len(repl):
                        new = new + c
                else:
                        c = repl[i]; i = i+1
@@ -182,7 +182,7 @@ def test():
                if not line: break
                if line[-1] == '\n': line = line[:-1]
                fields = split(line, delpat)
-               if len(fields) <> 3:
+               if len(fields) != 3:
                        print 'Sorry, not three fields'
                        print 'split:', `fields`
                        continue
index d7e83195236b98d9ca3b223b2b734d48b36b47ee..c1467b08e2d973af69cb87b584680be20fd44011 100644 (file)
@@ -185,7 +185,7 @@ class SGMLParser:
     # Internal -- parse comment, return length or -1 if not terminated
     def parse_comment(self, i):
         rawdata = self.rawdata
-        if rawdata[i:i+4] <> '<!--':
+        if rawdata[i:i+4] != '<!--':
             raise RuntimeError, 'unexpected call to handle_comment'
         match = commentclose.search(rawdata, i+4)
         if not match:
@@ -198,7 +198,7 @@ class SGMLParser:
     # Internal -- parse processing instr, return length or -1 if not terminated
     def parse_pi(self, i):
         rawdata = self.rawdata
-        if rawdata[i:i+2] <> '<?':
+        if rawdata[i:i+2] != '<?':
             raise RuntimeError, 'unexpected call to handle_pi'
         match = piclose.search(rawdata, i+2)
         if not match:
index 77cd22304cf7fd2ae141a881d49e074771ca09e0..064a9f83f7573ed16e163b0b8ff334cdf95aa3b9 100755 (executable)
@@ -319,7 +319,7 @@ class SMTP:
         if code == -1 and len(msg) == 0:
             raise SMTPServerDisconnected("Server not connected")
         self.ehlo_resp=msg
-        if code<>250:
+        if code != 250:
             return (code,msg)
         self.does_esmtp=1
         #parse the ehlo response -ddm
@@ -378,7 +378,7 @@ class SMTP:
         self.putcmd("data")
         (code,repl)=self.getreply()
         if self.debuglevel >0 : print "data:", (code,repl)
-        if code <> 354:
+        if code != 354:
             raise SMTPDataError(code,repl)
         else:
             q = quotedata(msg)
@@ -475,7 +475,7 @@ class SMTP:
                 esmtp_opts.append(option)
 
         (code,resp) = self.mail(from_addr, esmtp_opts)
-        if code <> 250:
+        if code != 250:
             self.rset()
             raise SMTPSenderRefused(code, resp, from_addr)
         senderrs={}
@@ -483,14 +483,14 @@ class SMTP:
             to_addrs = [to_addrs]
         for each in to_addrs:
             (code,resp)=self.rcpt(each, rcpt_options)
-            if (code <> 250) and (code <> 251):
+            if (code != 250) and (code != 251):
                 senderrs[each]=(code,resp)
         if len(senderrs)==len(to_addrs):
             # the server refused all our recipients
             self.rset()
             raise SMTPRecipientsRefused(senderrs)
-        (code,resp)=self.data(msg)
-        if code <> 250:
+        (code,resp) = self.data(msg)
+        if code != 250:
             self.rset()
             raise SMTPDataError(code, resp)
         #if we got here then somebody got our mail
index b2cdd307f4afd69d1159da50b838675f74afa8a6..b20a696e2dadfbc14a45fd96e20d13ebc8ef83e0 100644 (file)
@@ -56,7 +56,7 @@ tests = []
 
 def test_aifc(h, f):
        import aifc
-       if h[:4] <> 'FORM':
+       if h[:4] != 'FORM':
                return None
        if h[8:12] == 'AIFC':
                fmt = 'aifc'
@@ -105,7 +105,7 @@ tests.append(test_au)
 
 
 def test_hcom(h, f):
-       if h[65:69] <> 'FSSD' or h[128:132] <> 'HCOM':
+       if h[65:69] != 'FSSD' or h[128:132] != 'HCOM':
                return None
        divisor = get_long_be(h[128+16:128+20])
        return 'hcom', 22050/divisor, 1, -1, 8
@@ -114,7 +114,7 @@ tests.append(test_hcom)
 
 
 def test_voc(h, f):
-       if h[:20] <> 'Creative Voice File\032':
+       if h[:20] != 'Creative Voice File\032':
                return None
        sbseek = get_short_le(h[20:22])
        rate = 0
@@ -128,7 +128,7 @@ tests.append(test_voc)
 
 def test_wav(h, f):
        # 'RIFF' <len> 'WAVE' 'fmt ' <len>
-       if h[:4] <> 'RIFF' or h[8:12] <> 'WAVE' or h[12:16] <> 'fmt ':
+       if h[:4] != 'RIFF' or h[8:12] != 'WAVE' or h[12:16] != 'fmt ':
                return None
        style = get_short_le(h[20:22])
        nchannels = get_short_le(h[22:24])
@@ -140,7 +140,7 @@ tests.append(test_wav)
 
 
 def test_8svx(h, f):
-       if h[:4] <> 'FORM' or h[8:12] <> '8SVX':
+       if h[:4] != 'FORM' or h[8:12] != '8SVX':
                return None
        # Should decode it to get #channels -- assume always 1
        return '8svx', 0, 1, 0, 8
index b5147c233dc545952790a88e3f014d6427565c01..26f909426b812243673e1b13e5ab25e4d5ecfa52 100644 (file)
@@ -43,10 +43,10 @@ def forget_prefix(prefix):
 def forget_dir(prefix):
        """Forget about a directory and all entries in it, but not about
        entries in subdirectories."""
-       if prefix[-1:] == '/' and prefix <> '/':
+       if prefix[-1:] == '/' and prefix != '/':
                prefix = prefix[:-1]
        forget(prefix)
-       if prefix[-1:] <> '/':
+       if prefix[-1:] != '/':
                prefix = prefix + '/'
        n = len(prefix)
        for path in cache.keys():
@@ -62,7 +62,7 @@ def forget_except_prefix(prefix):
        Normally used with prefix = '/' after a chdir()."""
        n = len(prefix)
        for path in cache.keys():
-               if path[:n] <> prefix:
+               if path[:n] != prefix:
                        del cache[path]
 
 
index cbd17d26d48bb0c50259f784bbe2bd7dbdd18ed2..87dc6ee4dd31b85522bd4f7be80e39ced6cef41a 100644 (file)
@@ -13,7 +13,7 @@ def get_long_be(s):
 
 def gethdr(fp):
        """Read a sound header from an open file."""
-       if fp.read(4) <> MAGIC:
+       if fp.read(4) != MAGIC:
                raise error, 'gethdr: bad magic word'
        hdr_size = get_long_be(fp.read(4))
        data_size = get_long_be(fp.read(4))
index 52c5a89aafee3e707098d8a0c01c969374e89e92..25be46fb612fff8eca1d3865ba10445fd93e6ade 100644 (file)
@@ -63,7 +63,7 @@ def toaiff(filename):
                ret = _toaiff(filename, temps)
        finally:
                for temp in temps[:]:
-                       if temp <> ret:
+                       if temp != ret:
                                try:
                                        os.unlink(temp)
                                except os.error:
@@ -88,12 +88,12 @@ def _toaiff(filename, temps):
                if type(msg) == type(()) and len(msg) == 2 and \
                        type(msg[0]) == type(0) and type(msg[1]) == type(''):
                        msg = msg[1]
-               if type(msg) <> type(''):
+               if type(msg) != type(''):
                        msg = `msg`
                raise error, filename + ': ' + msg
        if ftype == 'aiff':
                return fname
-       if ftype == None or not table.has_key(ftype):
+       if ftype is None or not table.has_key(ftype):
                raise error, \
                        filename + ': unsupported audio file type ' + `ftype`
        temp = tempfile.mktemp()
index fa94bd549394c8a6f2e929d9bfd8bbaaf7d7fa18..27f1fa1a57c53b3e5e8f19afb06b7e70d8a5f28e 100644 (file)
@@ -16,7 +16,7 @@ def tzparse(tzstr):
        timezone, and 'daystart'/'hourstart' and 'dayend'/'hourend'
        specify the starting and ending points for daylight saving time."""
        global tzprog
-       if tzprog == None:
+       if tzprog is None:
                import re
                tzprog = re.compile(tzpat)
        match = tzprog.match(tzstr)
index e39b61bff341ef9a97f402770818652fe410bff4..3856d69de7d2d0333366c078b48c401e0babe5f8 100755 (executable)
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -46,9 +46,9 @@ def encode(in_file, out_file, name=None, mode=None):
     if in_file == '-':
         in_file = sys.stdin
     elif type(in_file) == type(''):
-        if name == None:
+        if name is None:
             name = os.path.basename(in_file)
-        if mode == None:
+        if mode is None:
             try:
                 mode = os.stat(in_file)[0]
             except AttributeError:
@@ -64,9 +64,9 @@ def encode(in_file, out_file, name=None, mode=None):
     #
     # Set defaults for name and mode
     #
-    if name == None:
+    if name is None:
         name = '-'
-    if mode == None:
+    if mode is None:
         mode = 0666
     #
     # Write the data
@@ -104,9 +104,9 @@ def decode(in_file, out_file=None, mode=None):
                 break
             except ValueError:
                 pass
-    if out_file == None:
+    if out_file is None:
         out_file = hdrfields[2]
-    if mode == None:
+    if mode is None:
         mode = string.atoi(hdrfields[1], 8)
     #
     # Open the output file
index 290d92ee48538c463907d6f33ef0c02354694d4e..c97975d8bfe0ecb7c3d13228f05a5b180a77e69d 100644 (file)
@@ -95,7 +95,7 @@ class Packer:
         self.pack_uint(0)
 
     def pack_farray(self, n, list, pack_item):
-        if len(list) <> n:
+        if len(list) != n:
             raise ValueError, 'wrong array size'
         for item in list:
             pack_item(item)
@@ -204,7 +204,7 @@ class Unpacker:
         while 1:
             x = self.unpack_uint()
             if x == 0: break
-            if x <> 1:
+            if x != 1:
                 raise ConversionError, '0 or 1 expected, got ' + `x`
             item = unpack_item()
             list.append(item)
index 2f925563de1262d40a92e662df4eb6f168812b8c..8bca0fc4b6364712b3bc33478e76ec22d29ece24 100644 (file)
@@ -421,7 +421,7 @@ class XMLParser:
     # Internal -- parse comment, return length or -1 if not terminated
     def parse_comment(self, i):
         rawdata = self.rawdata
-        if rawdata[i:i+4] <> '<!--':
+        if rawdata[i:i+4] != '<!--':
             raise Error('unexpected call to handle_comment')
         res = commentclose.search(rawdata, i+4)
         if res is None:
@@ -487,7 +487,7 @@ class XMLParser:
     # Internal -- handle CDATA tag, return length or -1 if not terminated
     def parse_cdata(self, i):
         rawdata = self.rawdata
-        if rawdata[i:i+9] <> '<![CDATA[':
+        if rawdata[i:i+9] != '<![CDATA[':
             raise Error('unexpected call to parse_cdata')
         res = cdataclose.search(rawdata, i+9)
         if res is None: