summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/Queue.py4
-rw-r--r--Lib/aifc.py40
-rw-r--r--Lib/bdb.py3
-rw-r--r--Lib/cmd.py3
-rw-r--r--Lib/ftplib.py7
-rwxr-xr-xLib/irix5/flp.py8
-rwxr-xr-xLib/irix5/readcd.py2
-rwxr-xr-xLib/irix5/torgb.py14
-rw-r--r--Lib/lib-stdwin/WindowSched.py2
-rw-r--r--Lib/lib-stdwin/basewin.py3
-rw-r--r--Lib/lib-stdwin/formatter.py5
-rw-r--r--Lib/lib-stdwin/mainloop.py3
-rw-r--r--Lib/lib-stdwin/srcwin.py11
-rw-r--r--Lib/lib-stdwin/wdb.py30
-rw-r--r--Lib/lib-stdwin/wdbframewin.py8
-rw-r--r--Lib/lib-stdwin/wdbsrcwin.py4
-rw-r--r--Lib/mimetools.py5
-rw-r--r--Lib/multifile.py5
-rw-r--r--Lib/mutex.py3
-rw-r--r--Lib/nntplib.py7
-rwxr-xr-xLib/pdb.py3
-rw-r--r--Lib/pipes.py11
-rwxr-xr-xLib/plat-irix5/flp.py8
-rwxr-xr-xLib/plat-irix5/readcd.py2
-rwxr-xr-xLib/plat-irix5/torgb.py14
-rwxr-xr-xLib/profile.py10
-rw-r--r--Lib/regexp.py5
-rw-r--r--Lib/repr.py5
-rw-r--r--Lib/rfc822.py8
-rw-r--r--Lib/sched.py3
-rwxr-xr-xLib/stdwin/WindowSched.py2
-rwxr-xr-xLib/stdwin/basewin.py3
-rwxr-xr-xLib/stdwin/formatter.py5
-rwxr-xr-xLib/stdwin/mainloop.py3
-rwxr-xr-xLib/stdwin/srcwin.py11
-rwxr-xr-xLib/stdwin/wdb.py30
-rwxr-xr-xLib/stdwin/wdbframewin.py8
-rwxr-xr-xLib/stdwin/wdbsrcwin.py4
-rw-r--r--Lib/sunau.py32
-rw-r--r--Lib/test/autotest.py5
-rw-r--r--Lib/toaiff.py16
-rw-r--r--Lib/whrandom.py5
42 files changed, 153 insertions, 207 deletions
diff --git a/Lib/Queue.py b/Lib/Queue.py
index eb089b8..0d69777 100644
--- a/Lib/Queue.py
+++ b/Lib/Queue.py
@@ -6,14 +6,12 @@ class Queue:
# Initialize a queue object with a given maximum size
# (If maxsize is <= 0, the maximum size is infinite)
- def init(self, maxsize):
- import thread
+ def __init__(self, maxsize):
self._init(maxsize)
self.mutex = thread.allocate_lock()
self.esema = thread.allocate_lock()
self.esema.acquire_lock()
self.fsema = thread.allocate_lock()
- return self
# Get an approximation of the queue size (not reliable!)
def qsize(self):
diff --git a/Lib/aifc.py b/Lib/aifc.py
index f833e92..a603314 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -287,7 +287,7 @@ def _write_float(f, x):
_write_long(f, lomant)
class Chunk:
- def init(self, file):
+ def __init__(self, file):
self.file = file
self.chunkname = self.file.read(4)
if len(self.chunkname) < 4:
@@ -295,7 +295,6 @@ class Chunk:
self.chunksize = _read_long(self.file)
self.size_read = 0
self.offset = self.file.tell()
- return self
def rewind(self):
self.file.seek(self.offset, 0)
@@ -333,7 +332,7 @@ class Aifc_read:
# These variables are available to the user though appropriate
# methods of this class:
# _file -- the open file with methods read(), close(), and seek()
- # set through the init() ir initfp() method
+ # set through the __init__() method
# _nchannels -- the number of audio channels
# available through the getnchannels() method
# _nframes -- the number of audio frames
@@ -389,7 +388,7 @@ class Aifc_read:
#DEBUG: SGI's soundfiler has a bug. There should
# be no need to check for EOF here.
try:
- chunk = Chunk().init(self._file)
+ chunk = Chunk(self._file)
except EOFError:
if formlength == 8:
print 'Warning: FORM chunk size too large'
@@ -433,10 +432,12 @@ class Aifc_read:
else:
params[3] = 24
self._decomp.SetParams(params)
- return self
- def init(self, filename):
- return self.initfp(builtin.open(filename, 'r'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ f = builtin.open(f, 'r')
+ # else, assume it is an open file object already
+ self.initfp(f)
def __del__(self):
if self._file:
@@ -610,7 +611,7 @@ class Aifc_write:
# These variables are user settable through appropriate methods
# of this class:
# _file -- the open file with methods write(), close(), tell(), seek()
- # set through the init() or initfp() method
+ # set through the __init__() method
# _comptype -- the AIFF-C compression type ('NONE' in AIFF)
# set through the setcomptype() or setparams() method
# _compname -- the human-readable AIFF-C compression type
@@ -634,13 +635,15 @@ class Aifc_write:
# _datalength -- the size of the audio samples written to the header
# _datawritten -- the size of the audio samples actually written
- def init(self, filename):
- self = self.initfp(builtin.open(filename, 'w'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ f = builtin.open(f, 'w')
+ # else, assume it is an open file object already
+ self.initfp(f)
if filename[-5:] == '.aiff':
self._aifc = 0
else:
self._aifc = 1
- return self
def initfp(self, file):
self._file = file
@@ -659,7 +662,6 @@ class Aifc_write:
self._markers = []
self._marklength = 0
self._aifc = 1 # AIFF-C is default
- return self
def __del__(self):
if self._file:
@@ -976,18 +978,12 @@ class Aifc_write:
_write_long(self._file, pos)
_write_string(self._file, name)
-def open(filename, mode):
+def open(f, mode):
if mode == 'r':
- return Aifc_read().init(filename)
+ return Aifc_read(f)
elif mode == 'w':
- return Aifc_write().init(filename)
+ return Aifc_write(f)
else:
raise Error, 'mode must be \'r\' or \'w\''
-def openfp(filep, mode):
- if mode == 'r':
- return Aifc_read().initfp(filep)
- elif mode == 'w':
- return Aifc_write().initfp(filep)
- else:
- raise Error, 'mode must be \'r\' or \'w\''
+openfp = open # B/W compatibility
diff --git a/Lib/bdb.py b/Lib/bdb.py
index bc0b282..6b3eab9 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -15,9 +15,6 @@ class Bdb: # Basic Debugger
def __init__(self):
self.breaks = {}
-
- def init(self): # BW compat only
- return self
def reset(self):
self.botframe = None
diff --git a/Lib/cmd.py b/Lib/cmd.py
index c4a347d..87ddcfa 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -13,9 +13,6 @@ class Cmd:
self.prompt = PROMPT
self.identchars = IDENTCHARS
self.lastcmd = ''
-
- def init(self): # BW compat only
- return self
def cmdloop(self):
stop = None
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index bfb0b5b..c441f1f 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -87,11 +87,6 @@ class FTP:
if args[1:]:
apply(self.login, args[1:])
- # Old init method (explicitly called by caller)
- def init(self, *args):
- if args:
- apply(self.connect, args)
-
# Connect to host. Arguments:
# - host: hostname to connect to (default previous host)
# - port: port to connect to (default previous port)
@@ -105,7 +100,7 @@ class FTP:
self.welcome = self.getresp()
# Get the welcome message from the server
- # (this is read and squirreled away by init())
+ # (this is read and squirreled away by connect())
def getwelcome(self):
if self.debugging: print '*welcome*', `self.welcome`
return self.welcome
diff --git a/Lib/irix5/flp.py b/Lib/irix5/flp.py
index ced5598..c3f6f3b 100755
--- a/Lib/irix5/flp.py
+++ b/Lib/irix5/flp.py
@@ -92,11 +92,11 @@ def _unpack_cache(altforms):
forms = {}
for name in altforms.keys():
altobj, altlist = altforms[name]
- obj = _newobj().init()
+ obj = _newobj()
obj.make(altobj)
list = []
for altobj in altlist:
- nobj = _newobj().init()
+ nobj = _newobj()
nobj.make(altobj)
list.append(nobj)
forms[name] = obj, list
@@ -235,8 +235,6 @@ def _parse_fd_form(file, name):
# Internal class: a convient place to store object info fields
#
class _newobj:
- def init(self):
- return self
def add(self, name, value):
self.__dict__[name] = value
def make(self, dict):
@@ -320,7 +318,7 @@ def _skip_object(file):
file.seek(pos)
def _parse_object(file):
- obj = _newobj().init()
+ obj = _newobj()
while 1:
pos = file.tell()
datum = _parse_1_line(file)
diff --git a/Lib/irix5/readcd.py b/Lib/irix5/readcd.py
index 7af6882..fffb6fe 100755
--- a/Lib/irix5/readcd.py
+++ b/Lib/irix5/readcd.py
@@ -30,7 +30,7 @@ class Readcd:
elif len(arg) == 2:
self.player = cd.open(arg[0], arg[1])
else:
- raise Error, 'bad init call'
+ raise Error, 'bad __init__ call'
self.list = []
self.callbacks = [(None, None)] * 8
self.parser = cd.createparser()
diff --git a/Lib/irix5/torgb.py b/Lib/irix5/torgb.py
index 61297d0..f283063 100755
--- a/Lib/irix5/torgb.py
+++ b/Lib/irix5/torgb.py
@@ -13,40 +13,40 @@ import imghdr
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromppm $IN $OUT', 'ff')
table['ppm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['pnm'] = t
table['pgm'] = t
table['pbm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromgif $IN $OUT', 'ff')
table['gif'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('tifftopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['tiff'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('rasttopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['rast'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('djpeg', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['jpeg'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
diff --git a/Lib/lib-stdwin/WindowSched.py b/Lib/lib-stdwin/WindowSched.py
index 67c3afb..56ca6f8 100644
--- a/Lib/lib-stdwin/WindowSched.py
+++ b/Lib/lib-stdwin/WindowSched.py
@@ -35,7 +35,7 @@ def delayfunc(msecs):
if event[0] <> WE_TIMER:
mainloop.dispatch(event)
-q = sched.scheduler().init(time.millitimer, delayfunc)
+q = sched.scheduler(time.millitimer, delayfunc)
# Export functions enter, enterabs and cancel just like a scheduler
#
diff --git a/Lib/lib-stdwin/basewin.py b/Lib/lib-stdwin/basewin.py
index f896fe2..7a43536 100644
--- a/Lib/lib-stdwin/basewin.py
+++ b/Lib/lib-stdwin/basewin.py
@@ -6,11 +6,10 @@ from stdwinevents import *
class BaseWindow:
- def init(self, title):
+ def __init__(self, title):
self.win = stdwin.open(title)
self.win.dispatch = self.dispatch
mainloop.register(self.win)
- return self
# def reopen(self):
# title = self.win.gettitle()
diff --git a/Lib/lib-stdwin/formatter.py b/Lib/lib-stdwin/formatter.py
index ac34ce9..7ddfc1d 100644
--- a/Lib/lib-stdwin/formatter.py
+++ b/Lib/lib-stdwin/formatter.py
@@ -13,7 +13,7 @@ class formatter:
# Pass the window's drawing object, and left, top, right
# coordinates of the drawing space as arguments.
#
- def init(self, d, left, top, right):
+ def __init__(self, d, left, top, right):
self.d = d # Drawing object
self.left = left # Left margin
self.right = right # Right margin
@@ -22,7 +22,6 @@ class formatter:
self.justify = 1
self.setfont('') # Default font
self._reset() # Prepare for new line
- return self
#
# Reset for start of fresh line.
#
@@ -190,7 +189,7 @@ def test():
w.change((0, 0), (1000, 1000))
elif type == WE_DRAW:
width, height = winsize
- f = formatter().init(w.begindrawing(), 0, 0, width)
+ f = formatter(w.begindrawing(), 0, 0, width)
f.center = center
f.justify = justify
if not center:
diff --git a/Lib/lib-stdwin/mainloop.py b/Lib/lib-stdwin/mainloop.py
index ca3e9ac..aa40c34 100644
--- a/Lib/lib-stdwin/mainloop.py
+++ b/Lib/lib-stdwin/mainloop.py
@@ -224,11 +224,10 @@ def dispatch(event):
#
class Dialog:
#
- def init(self, title):
+ def __init__(self, title):
self.window = stdwin.open(title)
self.window.dispatch = self.dispatch
register(self.window)
- return self
#
def close(self):
unregister(self.window)
diff --git a/Lib/lib-stdwin/srcwin.py b/Lib/lib-stdwin/srcwin.py
index a71c568..29b7801 100644
--- a/Lib/lib-stdwin/srcwin.py
+++ b/Lib/lib-stdwin/srcwin.py
@@ -10,7 +10,7 @@ MAXHEIGHT = 24
class TextWindow(basewin.BaseWindow):
- def init(self, title, contents):
+ def __init__(self, title, contents):
self.contents = contents
self.linecount = countlines(self.contents)
#
@@ -23,11 +23,10 @@ class TextWindow(basewin.BaseWindow):
width = WIDTH*stdwin.textwidth('0')
height = lh*min(MAXHEIGHT, self.linecount)
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, title)
+ basewin.BaseWindow.__init__(self, title)
#
self.win.setdocsize(0, self.bottom)
self.initeditor()
- return self
def initeditor(self):
r = (self.leftmargin, self.top), (self.rightmargin, self.bottom)
@@ -113,12 +112,12 @@ def countlines(text):
class SourceWindow(TextWindow):
- def init(self, filename):
+ def __init__(self, filename):
self.filename = filename
f = open(self.filename, 'r')
contents = f.read()
f.close()
- return TextWindow.init(self, self.filename, contents)
+ TextWindow.__init__(self, self.filename, contents)
# ------------------------------ testing ------------------------------
@@ -126,5 +125,5 @@ TESTFILE = 'srcwin.py'
def test():
import mainloop
- sw = SourceWindow().init(TESTFILE)
+ sw = SourceWindow(TESTFILE)
mainloop.mainloop()
diff --git a/Lib/lib-stdwin/wdb.py b/Lib/lib-stdwin/wdb.py
index c499296..d5c28bb 100644
--- a/Lib/lib-stdwin/wdb.py
+++ b/Lib/lib-stdwin/wdb.py
@@ -19,16 +19,15 @@ WdbDone = 'wdb.WdbDone' # Exception to continue execution
class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
- def init(self):
+ def __init__(self):
self.sourcewindows = {}
self.framewindows = {}
- self = bdb.Bdb.init(self)
+ bdb.Bdb.__init__(self)
width = WIDTH*stdwin.textwidth('0')
height = HEIGHT*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Stack--')
+ basewin.BaseWindow.__init__(self, '--Stack--')
self.closed = 0
- return self
def reset(self):
if self.closed: raise RuntimeError, 'already closed'
@@ -151,9 +150,8 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
if not self.sourcewindows.has_key(fn):
import wdbsrcwin
try:
- self.sourcewindows[fn] = \
- wdbsrcwin.DebuggerSourceWindow(). \
- init(self, fn)
+ self.sourcewindows[fn] = wdbsrcwin. \
+ DebuggerSourceWindow(self, fn)
except IOError:
stdwin.fleep()
return
@@ -170,7 +168,7 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_locals, name)
do_f = do_frame
@@ -182,7 +180,7 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_globals, name)
do_g = do_globalframe
@@ -274,27 +272,27 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
# Simplified interface
def run(statement):
- x = Wdb().init()
+ x = Wdb()
try: x.run(statement)
finally: x.close()
def runctx(statement, globals, locals):
- x = Wdb().init()
+ x = Wdb()
try: x.runctx(statement, globals, locals)
finally: x.close()
def runcall(*args):
- x = Wdb().init()
- try: apply(Pdb().init().runcall, args)
+ x = Wdb()
+ try: apply(x.runcall, args)
finally: x.close()
# Post-Mortem interface
def post_mortem(traceback):
- p = Pdb().init()
- p.reset()
- p.interaction(None, traceback)
+ x = Wdb()
+ x.reset()
+ x.interaction(None, traceback)
def pm():
import sys
diff --git a/Lib/lib-stdwin/wdbframewin.py b/Lib/lib-stdwin/wdbframewin.py
index f8b84e3..13bd173 100644
--- a/Lib/lib-stdwin/wdbframewin.py
+++ b/Lib/lib-stdwin/wdbframewin.py
@@ -17,7 +17,7 @@ MAXHEIGHT = 16
class FrameWindow(basewin.BaseWindow):
- def init(self, debugger, frame, dict, name):
+ def __init__(self, debugger, frame, dict, name):
self.debugger = debugger
self.frame = frame # Not used except for identity tests
self.dict = dict
@@ -27,12 +27,12 @@ class FrameWindow(basewin.BaseWindow):
width = WIDTH*stdwin.textwidth('0')
height = nl*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Frame ' + name + '--')
+ basewin.BaseWindow.__init__(
+ self, '--Frame ' + name + '--')
# XXX Should use current function name
self.initeditor()
self.displaylist = ['>>>', '', '-'*WIDTH]
self.refreshframe()
- return self
def initeditor(self):
r = (stdwin.textwidth('>>> '), 0), (30000, stdwin.lineheight())
@@ -81,7 +81,7 @@ class FrameWindow(basewin.BaseWindow):
self.debugger.framewindows[name].popup()
else:
self.debugger.framewindows[name] = \
- FrameWindow().init(self.debugger,
+ FrameWindow(self.debugger,
self.frame, value.__dict__,
name)
return
diff --git a/Lib/lib-stdwin/wdbsrcwin.py b/Lib/lib-stdwin/wdbsrcwin.py
index 6c5cde8..f79fab9 100644
--- a/Lib/lib-stdwin/wdbsrcwin.py
+++ b/Lib/lib-stdwin/wdbsrcwin.py
@@ -7,11 +7,11 @@ import srcwin
class DebuggerSourceWindow(srcwin.SourceWindow):
- def init(self, debugger, filename):
+ def __init__(self, debugger, filename):
self.debugger = debugger
self.curlineno = 0
self.focus = 0
- return srcwin.SourceWindow.init(self, filename)
+ srcwin.SourceWindow.__init__(self, filename)
def close(self):
del self.debugger.sourcewindows[self.filename]
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index 84eff9d..2a076f0 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -10,15 +10,14 @@ import rfc822
class Message(rfc822.Message):
- def init(self, fp):
- self = rfc822.Message.init(self, fp)
+ def __init__(self, fp):
+ rfc822.Message.__init__(self, fp)
self.encodingheader = \
self.getheader('content-transfer-encoding')
self.typeheader = \
self.getheader('content-type')
self.parsetype()
self.parseplist()
- return self
def parsetype(self):
str = self.typeheader
diff --git a/Lib/multifile.py b/Lib/multifile.py
index 4dd1b52..7a52ab6 100644
--- a/Lib/multifile.py
+++ b/Lib/multifile.py
@@ -6,7 +6,7 @@
# Suggested use:
#
# real_fp = open(...)
-# fp = MultiFile().init(real_fp)
+# fp = MultiFile(real_fp)
#
# "read some lines from fp"
# fp.push(separator)
@@ -31,14 +31,13 @@ Error = 'multifile.Error'
class MultiFile:
#
- def init(self, fp):
+ def __init__(self, fp):
self.fp = fp
self.stack = [] # Grows down
self.level = 0
self.last = 0
self.start = self.fp.tell()
self.posstack = [] # Grows down
- return self
#
def tell(self):
if self.level > 0:
diff --git a/Lib/mutex.py b/Lib/mutex.py
index 374f457..b897863 100644
--- a/Lib/mutex.py
+++ b/Lib/mutex.py
@@ -15,10 +15,9 @@ class mutex:
#
# Create a new mutex -- initially unlocked
#
- def init(self):
+ def __init__(self):
self.locked = 0
self.queue = []
- return self
#
# Test the locked bit of the mutex
#
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index c448d48..e7f0627 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -5,7 +5,7 @@
# Example:
#
# >>> from nntplib import NNTP
-# >>> s = NNTP().init('charon')
+# >>> s = NNTP('charon')
# >>> resp, count, first, last, name = s.group('nlnet.misc')
# >>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
# Group nlnet.misc has 525 articles, range 6960 to 7485
@@ -60,7 +60,7 @@ class NNTP:
# - host: hostname to connect to
# - port: port to connect to (default the standard NNTP port)
- def init(self, host, *args):
+ def __init__(self, host, *args):
if len(args) > 1: raise TypeError, 'too many args'
if args: port = args[0]
else: port = NNTP_PORT
@@ -71,10 +71,9 @@ class NNTP:
self.file = self.sock.makefile('r')
self.debugging = 0
self.welcome = self.getresp()
- return self
# Get the welcome message from the server
- # (this is read and squirreled away by init()).
+ # (this is read and squirreled away by __init__()).
# If the response code is 200, posting is allowed;
# if it 201, posting is not allowed
diff --git a/Lib/pdb.py b/Lib/pdb.py
index fd8835b..64451d5 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -16,9 +16,6 @@ class Pdb(bdb.Bdb, cmd.Cmd):
bdb.Bdb.__init__(self)
cmd.Cmd.__init__(self)
self.prompt = '(Pdb) '
-
- def init(self): # BW compat only
- return self
def reset(self):
bdb.Bdb.reset(self)
diff --git a/Lib/pipes.py b/Lib/pipes.py
index 426c377..0ae0b8c 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -29,7 +29,7 @@
# -----------
#
# To create a template:
-# t = Template().init()
+# t = Template()
#
# To add a conversion step to a template:
# t.append(command, kind)
@@ -85,11 +85,10 @@ stepkinds = [FILEIN_FILEOUT, STDIN_FILEOUT, FILEIN_STDOUT, STDIN_STDOUT, \
class Template:
- # Template().init() returns a fresh pipeline template
- def init(self):
+ # Template() returns a fresh pipeline template
+ def __init__(self):
self.debugging = 0
self.reset()
- return self
# t.__repr__() implements `t`
def __repr__(self):
@@ -102,7 +101,7 @@ class Template:
# t.clone() returns a new pipeline template with identical
# initial state as the current one
def clone(self):
- t = Template().init()
+ t = Template()
t.steps = self.steps[:]
t.debugging = self.debugging
return t
@@ -291,7 +290,7 @@ def quote(file):
def test():
import os
print 'Testing...'
- t = Template().init()
+ t = Template()
t.append('togif $IN $OUT', 'ff')
t.append('giftoppm', '--')
t.append('ppmtogif >$OUT', '-f')
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
index ced5598..c3f6f3b 100755
--- a/Lib/plat-irix5/flp.py
+++ b/Lib/plat-irix5/flp.py
@@ -92,11 +92,11 @@ def _unpack_cache(altforms):
forms = {}
for name in altforms.keys():
altobj, altlist = altforms[name]
- obj = _newobj().init()
+ obj = _newobj()
obj.make(altobj)
list = []
for altobj in altlist:
- nobj = _newobj().init()
+ nobj = _newobj()
nobj.make(altobj)
list.append(nobj)
forms[name] = obj, list
@@ -235,8 +235,6 @@ def _parse_fd_form(file, name):
# Internal class: a convient place to store object info fields
#
class _newobj:
- def init(self):
- return self
def add(self, name, value):
self.__dict__[name] = value
def make(self, dict):
@@ -320,7 +318,7 @@ def _skip_object(file):
file.seek(pos)
def _parse_object(file):
- obj = _newobj().init()
+ obj = _newobj()
while 1:
pos = file.tell()
datum = _parse_1_line(file)
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
index 7af6882..fffb6fe 100755
--- a/Lib/plat-irix5/readcd.py
+++ b/Lib/plat-irix5/readcd.py
@@ -30,7 +30,7 @@ class Readcd:
elif len(arg) == 2:
self.player = cd.open(arg[0], arg[1])
else:
- raise Error, 'bad init call'
+ raise Error, 'bad __init__ call'
self.list = []
self.callbacks = [(None, None)] * 8
self.parser = cd.createparser()
diff --git a/Lib/plat-irix5/torgb.py b/Lib/plat-irix5/torgb.py
index 61297d0..f283063 100755
--- a/Lib/plat-irix5/torgb.py
+++ b/Lib/plat-irix5/torgb.py
@@ -13,40 +13,40 @@ import imghdr
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromppm $IN $OUT', 'ff')
table['ppm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['pnm'] = t
table['pgm'] = t
table['pbm'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('fromgif $IN $OUT', 'ff')
table['gif'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('tifftopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['tiff'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('rasttopnm', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['rast'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('djpeg', '--')
t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
t.append('fromppm $IN $OUT', 'ff')
table['jpeg'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
diff --git a/Lib/profile.py b/Lib/profile.py
index 19b0476..502a4db 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -14,13 +14,12 @@ import marshal
class Profile:
- def init(self):
+ def __init__(self):
self.timings = {}
self.debug = None
self.call_level = 0
self.profile_func = None
self.profiling = 0
- return self
def profile(self, funcname):
if not self.profile_func:
@@ -230,12 +229,11 @@ def depth(frame):
return d
class Stats:
- def init(self, file):
+ def __init__(self, file):
f = open(file, 'r')
self.stats = marshal.load(f)
f.close()
self.stats_list = None
- return self
def print_stats(self):
print_title()
@@ -354,7 +352,7 @@ def f8(x):
# simplified user interface
def run(statement, *args):
- prof = Profile().init()
+ prof = Profile()
try:
prof.run(statement)
except SystemExit:
@@ -366,7 +364,7 @@ def run(statement, *args):
# test command with debugging
def debug():
- prof = Profile().init()
+ prof = Profile()
prof.debug = 1
try:
prof.run('import x; x.main()')
diff --git a/Lib/regexp.py b/Lib/regexp.py
index 755f65a..6136814 100644
--- a/Lib/regexp.py
+++ b/Lib/regexp.py
@@ -4,13 +4,12 @@ import regex
from regex_syntax import *
class Prog:
- def init(self, pat):
+ def __init__(self, pat):
save_syntax = regex.set_syntax(RE_SYNTAX_AWK)
try:
self.prog = regex.compile(pat)
finally:
xxx = regex.set_syntax(save_syntax)
- return self
def match(self, *args):
if len(args) == 2:
str, offset = args
@@ -27,7 +26,7 @@ class Prog:
return regs[:i]
def compile(pat):
- return Prog().init(pat)
+ return Prog(pat)
cache_pat = None
cache_prog = None
diff --git a/Lib/repr.py b/Lib/repr.py
index 68f374c..50ee6c9 100644
--- a/Lib/repr.py
+++ b/Lib/repr.py
@@ -3,7 +3,7 @@
import string
class Repr:
- def init(self):
+ def __init__(self):
self.maxlevel = 6
self.maxtuple = 6
self.maxlist = 6
@@ -11,7 +11,6 @@ class Repr:
self.maxstring = 30
self.maxlong = 40
self.maxother = 20
- return self
def repr(self, x):
return self.repr1(x, self.maxlevel)
def repr1(self, x, level):
@@ -79,5 +78,5 @@ class Repr:
s = s[:i] + '...' + s[len(s)-j:]
return s
-aRepr = Repr().init()
+aRepr = Repr()
repr = aRepr.repr
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index 63f2fb6..39ab6a6 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -10,8 +10,8 @@
# fp = open(file, 'r')
# (or use any other legal way of getting an open file object, e.g. use
# sys.stdin or call os.popen()).
-# Then pass the open file object to the init() method of Message:
-# m = Message().init(fp)
+# Then pass the open file object to the Message() constructor:
+# m = Message(fp)
#
# To get the text of a particular header there are several methods:
# str = m.getheader(name)
@@ -35,7 +35,7 @@ class Message:
# Initialize the class instance and read the headers.
- def init(self, fp):
+ def __init__(self, fp):
self.fp = fp
#
try:
@@ -49,8 +49,6 @@ class Message:
self.startofbody = self.fp.tell()
except IOError:
self.startofbody = None
- #
- return self
# Rewind the file to the start of the body (if seekable).
diff --git a/Lib/sched.py b/Lib/sched.py
index 29ccc2a..c838bad 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -34,11 +34,10 @@ class scheduler:
#
# Initialize a new instance, passing the time and delay functions
#
- def init(self, timefunc, delayfunc):
+ def __init__(self, timefunc, delayfunc):
self.queue = []
self.timefunc = timefunc
self.delayfunc = delayfunc
- return self
#
# Enter a new event in the queue at an absolute time.
# Returns an ID for the event which can be used
diff --git a/Lib/stdwin/WindowSched.py b/Lib/stdwin/WindowSched.py
index 67c3afb..56ca6f8 100755
--- a/Lib/stdwin/WindowSched.py
+++ b/Lib/stdwin/WindowSched.py
@@ -35,7 +35,7 @@ def delayfunc(msecs):
if event[0] <> WE_TIMER:
mainloop.dispatch(event)
-q = sched.scheduler().init(time.millitimer, delayfunc)
+q = sched.scheduler(time.millitimer, delayfunc)
# Export functions enter, enterabs and cancel just like a scheduler
#
diff --git a/Lib/stdwin/basewin.py b/Lib/stdwin/basewin.py
index f896fe2..7a43536 100755
--- a/Lib/stdwin/basewin.py
+++ b/Lib/stdwin/basewin.py
@@ -6,11 +6,10 @@ from stdwinevents import *
class BaseWindow:
- def init(self, title):
+ def __init__(self, title):
self.win = stdwin.open(title)
self.win.dispatch = self.dispatch
mainloop.register(self.win)
- return self
# def reopen(self):
# title = self.win.gettitle()
diff --git a/Lib/stdwin/formatter.py b/Lib/stdwin/formatter.py
index ac34ce9..7ddfc1d 100755
--- a/Lib/stdwin/formatter.py
+++ b/Lib/stdwin/formatter.py
@@ -13,7 +13,7 @@ class formatter:
# Pass the window's drawing object, and left, top, right
# coordinates of the drawing space as arguments.
#
- def init(self, d, left, top, right):
+ def __init__(self, d, left, top, right):
self.d = d # Drawing object
self.left = left # Left margin
self.right = right # Right margin
@@ -22,7 +22,6 @@ class formatter:
self.justify = 1
self.setfont('') # Default font
self._reset() # Prepare for new line
- return self
#
# Reset for start of fresh line.
#
@@ -190,7 +189,7 @@ def test():
w.change((0, 0), (1000, 1000))
elif type == WE_DRAW:
width, height = winsize
- f = formatter().init(w.begindrawing(), 0, 0, width)
+ f = formatter(w.begindrawing(), 0, 0, width)
f.center = center
f.justify = justify
if not center:
diff --git a/Lib/stdwin/mainloop.py b/Lib/stdwin/mainloop.py
index ca3e9ac..aa40c34 100755
--- a/Lib/stdwin/mainloop.py
+++ b/Lib/stdwin/mainloop.py
@@ -224,11 +224,10 @@ def dispatch(event):
#
class Dialog:
#
- def init(self, title):
+ def __init__(self, title):
self.window = stdwin.open(title)
self.window.dispatch = self.dispatch
register(self.window)
- return self
#
def close(self):
unregister(self.window)
diff --git a/Lib/stdwin/srcwin.py b/Lib/stdwin/srcwin.py
index a71c568..29b7801 100755
--- a/Lib/stdwin/srcwin.py
+++ b/Lib/stdwin/srcwin.py
@@ -10,7 +10,7 @@ MAXHEIGHT = 24
class TextWindow(basewin.BaseWindow):
- def init(self, title, contents):
+ def __init__(self, title, contents):
self.contents = contents
self.linecount = countlines(self.contents)
#
@@ -23,11 +23,10 @@ class TextWindow(basewin.BaseWindow):
width = WIDTH*stdwin.textwidth('0')
height = lh*min(MAXHEIGHT, self.linecount)
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, title)
+ basewin.BaseWindow.__init__(self, title)
#
self.win.setdocsize(0, self.bottom)
self.initeditor()
- return self
def initeditor(self):
r = (self.leftmargin, self.top), (self.rightmargin, self.bottom)
@@ -113,12 +112,12 @@ def countlines(text):
class SourceWindow(TextWindow):
- def init(self, filename):
+ def __init__(self, filename):
self.filename = filename
f = open(self.filename, 'r')
contents = f.read()
f.close()
- return TextWindow.init(self, self.filename, contents)
+ TextWindow.__init__(self, self.filename, contents)
# ------------------------------ testing ------------------------------
@@ -126,5 +125,5 @@ TESTFILE = 'srcwin.py'
def test():
import mainloop
- sw = SourceWindow().init(TESTFILE)
+ sw = SourceWindow(TESTFILE)
mainloop.mainloop()
diff --git a/Lib/stdwin/wdb.py b/Lib/stdwin/wdb.py
index c499296..d5c28bb 100755
--- a/Lib/stdwin/wdb.py
+++ b/Lib/stdwin/wdb.py
@@ -19,16 +19,15 @@ WdbDone = 'wdb.WdbDone' # Exception to continue execution
class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
- def init(self):
+ def __init__(self):
self.sourcewindows = {}
self.framewindows = {}
- self = bdb.Bdb.init(self)
+ bdb.Bdb.__init__(self)
width = WIDTH*stdwin.textwidth('0')
height = HEIGHT*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Stack--')
+ basewin.BaseWindow.__init__(self, '--Stack--')
self.closed = 0
- return self
def reset(self):
if self.closed: raise RuntimeError, 'already closed'
@@ -151,9 +150,8 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
if not self.sourcewindows.has_key(fn):
import wdbsrcwin
try:
- self.sourcewindows[fn] = \
- wdbsrcwin.DebuggerSourceWindow(). \
- init(self, fn)
+ self.sourcewindows[fn] = wdbsrcwin. \
+ DebuggerSourceWindow(self, fn)
except IOError:
stdwin.fleep()
return
@@ -170,7 +168,7 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_locals, name)
do_f = do_frame
@@ -182,7 +180,7 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
else:
import wdbframewin
self.framewindows[name] = \
- wdbframewin.FrameWindow().init(self, \
+ wdbframewin.FrameWindow(self, \
self.curframe, \
self.curframe.f_globals, name)
do_g = do_globalframe
@@ -274,27 +272,27 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger
# Simplified interface
def run(statement):
- x = Wdb().init()
+ x = Wdb()
try: x.run(statement)
finally: x.close()
def runctx(statement, globals, locals):
- x = Wdb().init()
+ x = Wdb()
try: x.runctx(statement, globals, locals)
finally: x.close()
def runcall(*args):
- x = Wdb().init()
- try: apply(Pdb().init().runcall, args)
+ x = Wdb()
+ try: apply(x.runcall, args)
finally: x.close()
# Post-Mortem interface
def post_mortem(traceback):
- p = Pdb().init()
- p.reset()
- p.interaction(None, traceback)
+ x = Wdb()
+ x.reset()
+ x.interaction(None, traceback)
def pm():
import sys
diff --git a/Lib/stdwin/wdbframewin.py b/Lib/stdwin/wdbframewin.py
index f8b84e3..13bd173 100755
--- a/Lib/stdwin/wdbframewin.py
+++ b/Lib/stdwin/wdbframewin.py
@@ -17,7 +17,7 @@ MAXHEIGHT = 16
class FrameWindow(basewin.BaseWindow):
- def init(self, debugger, frame, dict, name):
+ def __init__(self, debugger, frame, dict, name):
self.debugger = debugger
self.frame = frame # Not used except for identity tests
self.dict = dict
@@ -27,12 +27,12 @@ class FrameWindow(basewin.BaseWindow):
width = WIDTH*stdwin.textwidth('0')
height = nl*stdwin.lineheight()
stdwin.setdefwinsize(width, height)
- self = basewin.BaseWindow.init(self, '--Frame ' + name + '--')
+ basewin.BaseWindow.__init__(
+ self, '--Frame ' + name + '--')
# XXX Should use current function name
self.initeditor()
self.displaylist = ['>>>', '', '-'*WIDTH]
self.refreshframe()
- return self
def initeditor(self):
r = (stdwin.textwidth('>>> '), 0), (30000, stdwin.lineheight())
@@ -81,7 +81,7 @@ class FrameWindow(basewin.BaseWindow):
self.debugger.framewindows[name].popup()
else:
self.debugger.framewindows[name] = \
- FrameWindow().init(self.debugger,
+ FrameWindow(self.debugger,
self.frame, value.__dict__,
name)
return
diff --git a/Lib/stdwin/wdbsrcwin.py b/Lib/stdwin/wdbsrcwin.py
index 6c5cde8..f79fab9 100755
--- a/Lib/stdwin/wdbsrcwin.py
+++ b/Lib/stdwin/wdbsrcwin.py
@@ -7,11 +7,11 @@ import srcwin
class DebuggerSourceWindow(srcwin.SourceWindow):
- def init(self, debugger, filename):
+ def __init__(self, debugger, filename):
self.debugger = debugger
self.curlineno = 0
self.focus = 0
- return srcwin.SourceWindow.init(self, filename)
+ srcwin.SourceWindow.__init__(self, filename)
def close(self):
del self.debugger.sourcewindows[self.filename]
diff --git a/Lib/sunau.py b/Lib/sunau.py
index 2cb35a7..08e4d20 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -192,11 +192,12 @@ class Au_read:
break
else:
self._info = ''
- return self
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'r'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'r')
+ self.initfp(f)
def __del__(self):
if self._file:
@@ -277,9 +278,11 @@ class Au_read:
self._file = None
class Au_write:
- def init(self, filename):
- import builtin
- return self.initfp(builtin.open(filename, 'w'))
+ def __init__(self, f):
+ if type(f) == type(''):
+ import builtin
+ f = builtin.open(f, 'w')
+ self.initfp(f)
def initfp(self, file):
self._file = file
@@ -293,7 +296,6 @@ class Au_write:
self._datalength = 0
self._info = ''
self._comptype = 'ULAW' # default is U-law
- return self
def __del__(self):
if self._file:
@@ -453,18 +455,12 @@ class Au_write:
self._datalength = self._datawritten
self._file.seek(0, 2)
-def open(filename, mode):
+def open(f, mode):
if mode == 'r':
- return Au_read().init(filename)
+ return Au_read(f)
elif mode == 'w':
- return Au_write().init(filename)
+ return Au_write(f)
else:
raise Error, "mode must be 'r' or 'w'"
-def openfp(filep, mode):
- if mode == 'r':
- return Au_read().initfp(filep)
- elif mode == 'w':
- return Au_write().initfp(filep)
- else:
- raise Error, "mode must be 'r' or 'w'"
+openfp = open
diff --git a/Lib/test/autotest.py b/Lib/test/autotest.py
index 57e3674..79d9b11 100644
--- a/Lib/test/autotest.py
+++ b/Lib/test/autotest.py
@@ -42,9 +42,8 @@ TestFailed = 'autotest.TestFailed'
# Class substituted for sys.stdout, to compare it with the given file
class Compare:
- def init(self, filename):
+ def __init__(self, filename):
self.fp = open(filename, 'r')
- return self
def write(self, data):
expected = self.fp.read(len(data))
if data <> expected:
@@ -59,7 +58,7 @@ def main():
filename = findfile('testall.out')
real_stdout = sys.stdout
try:
- sys.stdout = Compare().init(filename)
+ sys.stdout = Compare(filename)
import testall
finally:
sys.stdout = real_stdout
diff --git a/Lib/toaiff.py b/Lib/toaiff.py
index d2f5cd7..0001be0 100644
--- a/Lib/toaiff.py
+++ b/Lib/toaiff.py
@@ -13,7 +13,7 @@ import whatsound
table = {}
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t au - -t aiff -r 8000 -', '--')
table['au'] = t
@@ -23,31 +23,31 @@ table['au'] = t
# XXX files sampled at 5.5k or 7.333k; however this means that files
# XXX sampled at 11k are unnecessarily expanded.
# XXX Similar comments apply to some other file types.
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t hcom - -t aiff -r 22050 -', '--')
table['hcom'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t voc - -t aiff -r 11025 -', '--')
table['voc'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t wav - -t aiff -', '--')
table['wav'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t 8svx - -t aiff -r 16000 -', '--')
table['8svx'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t sndt - -t aiff -r 16000 -', '--')
table['sndt'] = t
-t = pipes.Template().init()
+t = pipes.Template()
t.append('sox -t sndr - -t aiff -r 16000 -', '--')
table['sndr'] = t
-uncompress = pipes.Template().init()
+uncompress = pipes.Template()
uncompress.append('uncompress', '--')
diff --git a/Lib/whrandom.py b/Lib/whrandom.py
index 0a34690..c7881b5 100644
--- a/Lib/whrandom.py
+++ b/Lib/whrandom.py
@@ -35,7 +35,7 @@ class whrandom:
# Without arguments, initialize from current time.
# With arguments (x, y, z), initialize from them.
#
- def init(self, *xyz):
+ def __init__(self, *xyz):
if not xyz:
# Initialize from current time
import time
@@ -47,7 +47,6 @@ class whrandom:
# Initialize from arguments (x, y, z)
x, y, z = xyz
self.seed(x, y, z)
- return self
#
# Set the seed from (x, y, z).
# These must be integers in the range [0, 256).
@@ -97,7 +96,7 @@ class whrandom:
# Initialize from the current time
#
-_inst = whrandom().init()
+_inst = whrandom()
seed = _inst.seed
random = _inst.random
uniform = _inst.uniform