summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-05-06 14:28:19 (GMT)
committerGuido van Rossum <guido@python.org>1994-05-06 14:28:19 (GMT)
commit2922c6dabbd9f8e49975ff3d972644c7212882e9 (patch)
tree3ea84b9ee77599005eee665078cb486deb7209e6 /Lib
parente4c6131baab4d09d31d280fa7dbca76cbe319dbb (diff)
downloadcpython-2922c6dabbd9f8e49975ff3d972644c7212882e9.zip
cpython-2922c6dabbd9f8e49975ff3d972644c7212882e9.tar.gz
cpython-2922c6dabbd9f8e49975ff3d972644c7212882e9.tar.bz2
Changes to use default argument values where possible
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gopherlib.py12
-rw-r--r--Lib/httplib.py12
-rwxr-xr-xLib/mailbox.py12
-rw-r--r--Lib/random.py6
4 files changed, 13 insertions, 29 deletions
diff --git a/Lib/gopherlib.py b/Lib/gopherlib.py
index 71413ba..7550d5c 100644
--- a/Lib/gopherlib.py
+++ b/Lib/gopherlib.py
@@ -54,14 +54,10 @@ CRLF = '\r\n'
TAB = '\t'
# Send a selector to a given host and port, return a file with the reply
-def send_selector(selector, host, *args):
+def send_selector(selector, host, port = 0):
import socket
import string
- if args:
- if args[1:]: raise TypeError, 'too many args'
- port = args[0]
- else:
- port = None
+ if not port:
i = string.find(host, ':')
if i >= 0:
host, port = host[:i], string.atoi(host[i+1:])
@@ -76,8 +72,8 @@ def send_selector(selector, host, *args):
return s.makefile('r')
# Send a selector and a query string
-def send_query(selector, query, host, *args):
- return apply(send_selector, (selector + '\t' + query, host) + args)
+def send_query(selector, query, host, port = 0):
+ return send_selector(selector + '\t' + query, host, port)
# The following functions interpret the data returned by the gopher
# server according to the expected type, e.g. textfile or directory
diff --git a/Lib/httplib.py b/Lib/httplib.py
index d494e21..362b38d 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -43,20 +43,16 @@ replyprog = regex.compile(replypat)
class HTTP:
- def __init__(self, *args):
+ def __init__(self, host = '', port = 0):
self.debuglevel = 0
- if args: apply(self.connect, args)
+ if host: self.connect(host, port)
def set_debuglevel(self, debuglevel):
self.debuglevel = debuglevel
- def connect(self, host, *args):
- if args:
- if args[1:]: raise TypeError, 'too many args'
- port = args[0]
- else:
+ def connect(self, host, port = 0):
+ if not port:
i = string.find(host, ':')
- port = None
if i >= 0:
host, port = host[:i], host[i+1:]
try: port = string.atoi(port)
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index b7a5598..e93512a 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -35,24 +35,20 @@ class _Subfile:
self.stop = stop
self.pos = self.start
- def read(self, *args):
+ def read(self, length = None):
if self.pos >= self.stop:
return ''
- if args == ():
+ if length is None:
length = self.stop - self.pos
- else:
- length = args[0]
self.fp.seek(self.pos)
self.pos = self.pos + length
return self.fp.read(length)
- def readline(self, *args):
+ def readline(self, length = None):
if self.pos >= self.stop:
return ''
- if args == ():
+ if length is None:
length = self.stop - self.pos
- else:
- length = args[0]
self.fp.seek(self.pos)
data = self.fp.readline(length)
if len(data) < length:
diff --git a/Lib/random.py b/Lib/random.py
index 0d2f06b..608203f 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -214,15 +214,11 @@ def betavariate(alpha, beta):
# -------------------- test program --------------------
-def test(*args):
+def test(N = 200):
print 'TWOPI =', TWOPI
print 'LOG4 =', LOG4
print 'NV_MAGICCONST =', NV_MAGICCONST
print 'SG_MAGICCONST =', SG_MAGICCONST
- N = 200
- if args:
- if args[1:]: print 'Excess test() arguments ignored'
- N = args[0]
test_generator(N, 'random()')
test_generator(N, 'normalvariate(0.0, 1.0)')
test_generator(N, 'lognormvariate(0.0, 1.0)')