summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xDemo/classes/Dates.py70
-rw-r--r--Demo/threads/fcmp.py6
-rw-r--r--Lib/ctypes/test/test_pointers.py2
-rwxr-xr-xLib/lib-tk/Tix.py4
-rw-r--r--Lib/markupbase.py2
-rw-r--r--Lib/plat-mac/EasyDialogs.py4
-rwxr-xr-xLib/smtplib.py2
-rw-r--r--Lib/test/test_builtin.py2
-rw-r--r--Lib/test/test_tempfile.py2
-rwxr-xr-xTools/webchecker/webchecker.py4
10 files changed, 49 insertions, 49 deletions
diff --git a/Demo/classes/Dates.py b/Demo/classes/Dates.py
index f8f0634..6494b6a 100755
--- a/Demo/classes/Dates.py
+++ b/Demo/classes/Dates.py
@@ -59,32 +59,32 @@ del dbm, dim
_INT_TYPES = type(1), type(1L)
-def _is_leap( year ): # 1 if leap year, else 0
+def _is_leap(year): # 1 if leap year, else 0
if year % 4 != 0: return 0
if year % 400 == 0: return 1
return year % 100 != 0
-def _days_in_year( year ): # number of days in year
+def _days_in_year(year): # number of days in year
return 365 + _is_leap(year)
-def _days_before_year( year ): # number of days before year
+def _days_before_year(year): # number of days before year
return year*365L + (year+3)/4 - (year+99)/100 + (year+399)/400
-def _days_in_month( month, year ): # number of days in month of year
+def _days_in_month(month, year): # number of days in month of year
if month == 2 and _is_leap(year): return 29
return _DAYS_IN_MONTH[month-1]
-def _days_before_month( month, year ): # number of days in year before month
+def _days_before_month(month, year): # number of days in year before month
return _DAYS_BEFORE_MONTH[month-1] + (month > 2 and _is_leap(year))
-def _date2num( date ): # compute ordinal of date.month,day,year
- return _days_before_year( date.year ) + \
- _days_before_month( date.month, date.year ) + \
+def _date2num(date): # compute ordinal of date.month,day,year
+ return _days_before_year(date.year) + \
+ _days_before_month(date.month, date.year) + \
date.day
-_DI400Y = _days_before_year( 400 ) # number of days in 400 years
+_DI400Y = _days_before_year(400) # number of days in 400 years
-def _num2date( n ): # return date with ordinal n
+def _num2date(n): # return date with ordinal n
if type(n) not in _INT_TYPES:
raise TypeError, 'argument must be integer: %r' % type(n)
@@ -95,53 +95,53 @@ def _num2date( n ): # return date with ordinal n
n400 = (n-1)/_DI400Y # # of 400-year blocks preceding
year, n = 400 * n400, n - _DI400Y * n400
more = n / 365
- dby = _days_before_year( more )
+ dby = _days_before_year(more)
if dby >= n:
more = more - 1
- dby = dby - _days_in_year( more )
+ dby = dby - _days_in_year(more)
year, n = year + more, int(n - dby)
try: year = int(year) # chop to int, if it fits
except (ValueError, OverflowError): pass
- month = min( n/29 + 1, 12 )
- dbm = _days_before_month( month, year )
+ month = min(n/29 + 1, 12)
+ dbm = _days_before_month(month, year)
if dbm >= n:
month = month - 1
- dbm = dbm - _days_in_month( month, year )
+ dbm = dbm - _days_in_month(month, year)
ans.month, ans.day, ans.year = month, n-dbm, year
return ans
-def _num2day( n ): # return weekday name of day with ordinal n
+def _num2day(n): # return weekday name of day with ordinal n
return _DAY_NAMES[ int(n % 7) ]
class Date:
- def __init__( self, month, day, year ):
+ def __init__(self, month, day, year):
if not 1 <= month <= 12:
raise ValueError, 'month must be in 1..12: %r' % (month,)
- dim = _days_in_month( month, year )
+ dim = _days_in_month(month, year)
if not 1 <= day <= dim:
raise ValueError, 'day must be in 1..%r: %r' % (dim, day)
self.month, self.day, self.year = month, day, year
- self.ord = _date2num( self )
+ self.ord = _date2num(self)
# don't allow setting existing attributes
- def __setattr__( self, name, value ):
+ def __setattr__(self, name, value):
if self.__dict__.has_key(name):
raise AttributeError, 'read-only attribute ' + name
self.__dict__[name] = value
- def __cmp__( self, other ):
- return cmp( self.ord, other.ord )
+ def __cmp__(self, other):
+ return cmp(self.ord, other.ord)
# define a hash function so dates can be used as dictionary keys
- def __hash__( self ):
- return hash( self.ord )
+ def __hash__(self):
+ return hash(self.ord)
# print as, e.g., Mon 16 Aug 1993
- def __repr__( self ):
+ def __repr__(self):
return '%.3s %2d %.3s %r' % (
self.weekday(),
self.day,
@@ -149,33 +149,33 @@ class Date:
self.year)
# Python 1.1 coerces neither int+date nor date+int
- def __add__( self, n ):
+ def __add__(self, n):
if type(n) not in _INT_TYPES:
raise TypeError, 'can\'t add %r to date' % type(n)
- return _num2date( self.ord + n )
+ return _num2date(self.ord + n)
__radd__ = __add__ # handle int+date
# Python 1.1 coerces neither date-int nor date-date
- def __sub__( self, other ):
+ def __sub__(self, other):
if type(other) in _INT_TYPES: # date-int
- return _num2date( self.ord - other )
+ return _num2date(self.ord - other)
else:
return self.ord - other.ord # date-date
# complain about int-date
- def __rsub__( self, other ):
+ def __rsub__(self, other):
raise TypeError, 'Can\'t subtract date from integer'
- def weekday( self ):
- return _num2day( self.ord )
+ def weekday(self):
+ return _num2day(self.ord)
def today():
import time
local = time.localtime(time.time())
- return Date( local[1], local[2], local[0] )
+ return Date(local[1], local[2], local[0])
DateTestError = 'DateTestError'
-def test( firstyear, lastyear ):
+def test(firstyear, lastyear):
a = Date(9,30,1913)
b = Date(9,30,1914)
if repr(a) != 'Tue 30 Sep 1913':
@@ -207,7 +207,7 @@ def test( firstyear, lastyear ):
# verify date<->number conversions for first and last days for
# all years in firstyear .. lastyear
- lord = _days_before_year( firstyear )
+ lord = _days_before_year(firstyear)
y = firstyear
while y <= lastyear:
ford = lord + 1
diff --git a/Demo/threads/fcmp.py b/Demo/threads/fcmp.py
index 83ebe01..27af76d 100644
--- a/Demo/threads/fcmp.py
+++ b/Demo/threads/fcmp.py
@@ -4,14 +4,14 @@ from Coroutine import *
# fringe visits a nested list in inorder, and detaches for each non-list
# element; raises EarlyExit after the list is exhausted
-def fringe( co, list ):
+def fringe(co, list):
for x in list:
if type(x) is type([]):
fringe(co, x)
else:
co.back(x)
-def printinorder( list ):
+def printinorder(list):
co = Coroutine()
f = co.create(fringe, co, list)
try:
@@ -27,7 +27,7 @@ x = [0, 1, [2, [3]], [4,5], [[[6]]] ]
printinorder(x) # 0 1 2 3 4 5 6
# fcmp lexicographically compares the fringes of two nested lists
-def fcmp( l1, l2 ):
+def fcmp(l1, l2):
co1 = Coroutine(); f1 = co1.create(fringe, co1, l1)
co2 = Coroutine(); f2 = co2.create(fringe, co2, l2)
while 1:
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index 600bb75..a7a2802 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -133,7 +133,7 @@ class PointersTestCase(unittest.TestCase):
self.failUnlessEqual(p[0], 42)
self.failUnlessEqual(p.contents.value, 42)
- def test_charpp( self ):
+ def test_charpp(self):
"""Test that a character pointer-to-pointer is correctly passed"""
dll = CDLL(_ctypes_test.__file__)
func = dll._testfunc_c_p_p
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 14c3c24..33ac519 100755
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/lib-tk/Tix.py
@@ -468,7 +468,7 @@ class DisplayStyle:
"""DisplayStyle - handle configuration options shared by
(multiple) Display Items"""
- def __init__(self, itemtype, cnf={}, **kw ):
+ def __init__(self, itemtype, cnf={}, **kw):
master = _default_root # global from Tkinter
if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
elif not master and kw.has_key('refwindow'): master= kw['refwindow']
@@ -480,7 +480,7 @@ class DisplayStyle:
def __str__(self):
return self.stylename
- def _options(self, cnf, kw ):
+ def _options(self, cnf, kw):
if kw and cnf:
cnf = _cnfmerge((cnf, kw))
elif kw:
diff --git a/Lib/markupbase.py b/Lib/markupbase.py
index 85b07a2..24808d1 100644
--- a/Lib/markupbase.py
+++ b/Lib/markupbase.py
@@ -140,7 +140,7 @@ class ParserBase:
# Internal -- parse a marked section
# Override this to handle MS-word extension syntax <![if word]>content<![endif]>
- def parse_marked_section( self, i, report=1 ):
+ def parse_marked_section(self, i, report=1):
rawdata= self.rawdata
assert rawdata[i:i+3] == '<![', "unexpected call to parse_marked_section()"
sectName, j = self._scan_name( i+3, i )
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py
index c622d30..b33d1be 100644
--- a/Lib/plat-mac/EasyDialogs.py
+++ b/Lib/plat-mac/EasyDialogs.py
@@ -262,7 +262,7 @@ class ProgressBar:
self.w.ShowWindow()
self.d.DrawDialog()
- def __del__( self ):
+ def __del__(self):
if self.w:
self.w.BringToFront()
self.w.HideWindow()
@@ -274,7 +274,7 @@ class ProgressBar:
self.w.BringToFront()
self.w.SetWTitle(newstr)
- def label( self, *newstr ):
+ def label(self, *newstr):
"""label(text) - Set text in progress box"""
self.w.BringToFront()
if newstr:
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 07916cc..9c8c4fa 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -150,7 +150,7 @@ class SSLFakeFile:
It only supports what is needed in smtplib.
"""
- def __init__( self, sslobj):
+ def __init__(self, sslobj):
self.sslobj = sslobj
def readline(self):
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index ed28153..dcc565a 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -362,7 +362,7 @@ class BuiltinTest(unittest.TestCase):
_cells = {}
def __setitem__(self, key, formula):
self._cells[key] = formula
- def __getitem__(self, key ):
+ def __getitem__(self, key):
return eval(self._cells[key], globals(), self)
ss = SpreadSheet()
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index e274c5b..aeaa77e 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -390,7 +390,7 @@ test_classes.append(test_gettempdir)
class test_mkstemp(TC):
"""Test mkstemp()."""
- def do_create(self, dir=None, pre="", suf="", ):
+ def do_create(self, dir=None, pre="", suf=""):
if dir is None:
dir = tempfile.gettempdir()
try:
diff --git a/Tools/webchecker/webchecker.py b/Tools/webchecker/webchecker.py
index d918a0c..e2b4c71 100755
--- a/Tools/webchecker/webchecker.py
+++ b/Tools/webchecker/webchecker.py
@@ -784,7 +784,7 @@ class MyHTMLParser(sgmllib.SGMLParser):
self.url = url
sgmllib.SGMLParser.__init__(self)
- def check_name_id( self, attributes ):
+ def check_name_id(self, attributes):
""" Check the name or id attributes on an element.
"""
# We must rescue the NAME or id (name is deprecated in XHTML)
@@ -799,7 +799,7 @@ class MyHTMLParser(sgmllib.SGMLParser):
else: self.names.append(value)
break
- def unknown_starttag( self, tag, attributes ):
+ def unknown_starttag(self, tag, attributes):
""" In XHTML, you can have id attributes on any element.
"""
self.check_name_id(attributes)