diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-03-17 08:00:19 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-03-17 08:00:19 (GMT) |
commit | d91085598f5185b267ea51a3f615da9527af2ed2 (patch) | |
tree | 80849b9455438e9963a61d7aff3fc3b060213553 /Demo | |
parent | fe55464f393fc002fd0911a4d8dba6694723d408 (diff) | |
download | cpython-d91085598f5185b267ea51a3f615da9527af2ed2.zip cpython-d91085598f5185b267ea51a3f615da9527af2ed2.tar.gz cpython-d91085598f5185b267ea51a3f615da9527af2ed2.tar.bz2 |
Remove apply()
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/classes/bitvec.py | 12 | ||||
-rw-r--r-- | Demo/metaclasses/Eiffel.py | 6 | ||||
-rw-r--r-- | Demo/metaclasses/Meta.py | 4 | ||||
-rw-r--r-- | Demo/metaclasses/Simple.py | 2 | ||||
-rw-r--r-- | Demo/metaclasses/Synch.py | 4 | ||||
-rw-r--r-- | Demo/metaclasses/Trace.py | 6 | ||||
-rwxr-xr-x | Demo/pdist/RCSProxy.py | 2 | ||||
-rwxr-xr-x | Demo/pdist/client.py | 5 | ||||
-rwxr-xr-x | Demo/pdist/server.py | 4 | ||||
-rw-r--r-- | Demo/threads/Coroutine.py | 2 | ||||
-rw-r--r-- | Demo/threads/Generator.py | 2 | ||||
-rw-r--r-- | Demo/threads/find.py | 5 | ||||
-rw-r--r-- | Demo/tix/tixwidgets.py | 3 | ||||
-rwxr-xr-x | Demo/tkinter/guido/AttrDialog.py | 3 | ||||
-rwxr-xr-x | Demo/tkinter/guido/ManPage.py | 4 | ||||
-rwxr-xr-x | Demo/tkinter/guido/ShellWindow.py | 2 | ||||
-rwxr-xr-x | Demo/tkinter/guido/kill.py | 2 | ||||
-rw-r--r-- | Demo/tkinter/guido/optionmenu.py | 2 | ||||
-rw-r--r-- | Demo/tkinter/guido/sortvisu.py | 3 | ||||
-rwxr-xr-x | Demo/tkinter/guido/svkill.py | 4 | ||||
-rw-r--r-- | Demo/tkinter/matt/window-creation-w-location.py | 2 |
21 files changed, 37 insertions, 42 deletions
diff --git a/Demo/classes/bitvec.py b/Demo/classes/bitvec.py index 2894a56..934d33a 100755 --- a/Demo/classes/bitvec.py +++ b/Demo/classes/bitvec.py @@ -172,7 +172,7 @@ class BitVec: def __cmp__(self, other, *rest): #rprt('%r.__cmp__%r\n' % (self, (other,) + rest)) if type(other) != type(self): - other = apply(bitvec, (other, ) + rest) + other = bitvec(other, *rest) #expensive solution... recursive binary, with slicing length = self._len if length == 0 or other._len == 0: @@ -237,7 +237,7 @@ class BitVec: #rprt('%s.__setslice__%r\n' % (self, (i, j, sequence) + rest)) i, j = _check_slice(self._len, i, j) if type(sequence) != type(self): - sequence = apply(bitvec, (sequence, ) + rest) + sequence = bitvec(sequence, *rest) #sequence is now of our own type ls_part = self[:i] ms_part = self[j:] @@ -283,7 +283,7 @@ class BitVec: def __and__(self, otherseq, *rest): #rprt('%r.__and__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): - otherseq = apply(bitvec, (otherseq, ) + rest) + otherseq = bitvec(otherseq, *rest) #sequence is now of our own type return BitVec(self._data & otherseq._data, \ min(self._len, otherseq._len)) @@ -292,7 +292,7 @@ class BitVec: def __xor__(self, otherseq, *rest): #rprt('%r.__xor__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): - otherseq = apply(bitvec, (otherseq, ) + rest) + otherseq = bitvec(otherseq, *rest) #sequence is now of our own type return BitVec(self._data ^ otherseq._data, \ max(self._len, otherseq._len)) @@ -301,7 +301,7 @@ class BitVec: def __or__(self, otherseq, *rest): #rprt('%r.__or__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): - otherseq = apply(bitvec, (otherseq, ) + rest) + otherseq = bitvec(otherseq, *rest) #sequence is now of our own type return BitVec(self._data | otherseq._data, \ max(self._len, otherseq._len)) @@ -316,7 +316,7 @@ class BitVec: #needed for *some* of the arithmetic operations #rprt('%r.__coerce__%r\n' % (self, (otherseq,) + rest)) if type(otherseq) != type(self): - otherseq = apply(bitvec, (otherseq, ) + rest) + otherseq = bitvec(otherseq, *rest) return self, otherseq def __int__(self): diff --git a/Demo/metaclasses/Eiffel.py b/Demo/metaclasses/Eiffel.py index 24fac14..8c39746 100644 --- a/Demo/metaclasses/Eiffel.py +++ b/Demo/metaclasses/Eiffel.py @@ -82,10 +82,10 @@ class EiffelMethodWrapper(MetaMethodWrapper): def __call__(self, *args, **kw): if self.pre: - apply(self.pre, args, kw) - Result = apply(self.func, (self.inst,) + args, kw) + self.pre(*args, **kw) + Result = self.func(self.inst, *args, **kw) if self.post: - apply(self.post, (Result,) + args, kw) + self.post(Result, *args, **kw) return Result class EiffelHelper(MetaHelper): diff --git a/Demo/metaclasses/Meta.py b/Demo/metaclasses/Meta.py index 580f582..9529e0f 100644 --- a/Demo/metaclasses/Meta.py +++ b/Demo/metaclasses/Meta.py @@ -14,7 +14,7 @@ class MetaMethodWrapper: self.__name__ = self.func.__name__ def __call__(self, *args, **kw): - return apply(self.func, (self.inst,) + args, kw) + return self.func(self.inst, *args, **kw) class MetaHelper: @@ -86,7 +86,7 @@ class MetaClass: init = inst.__getattr__('__init__') except AttributeError: init = lambda: None - apply(init, args, kw) + init(*args, **kw) return inst diff --git a/Demo/metaclasses/Simple.py b/Demo/metaclasses/Simple.py index 03ed259..e3e54f7 100644 --- a/Demo/metaclasses/Simple.py +++ b/Demo/metaclasses/Simple.py @@ -28,7 +28,7 @@ class BoundMethod: self.instance = instance def __call__(self, *args): print "calling", self.function, "for", self.instance, "with", args - return apply(self.function, (self.instance,) + args) + return self.function(self.instance, *args) Trace = Tracing('Trace', (), {}) diff --git a/Demo/metaclasses/Synch.py b/Demo/metaclasses/Synch.py index 80e52d9..cd13e86 100644 --- a/Demo/metaclasses/Synch.py +++ b/Demo/metaclasses/Synch.py @@ -148,10 +148,10 @@ from Meta import MetaClass, MetaHelper, MetaMethodWrapper class LockingMethodWrapper(MetaMethodWrapper): def __call__(self, *args, **kw): if self.__name__[:1] == '_' and self.__name__[1:] != '_': - return apply(self.func, (self.inst,) + args, kw) + return self.func(self.inst, *args, **kw) self.inst.__lock__.acquire() try: - return apply(self.func, (self.inst,) + args, kw) + return self.func(self.inst, *args, **kw) finally: self.inst.__lock__.release() diff --git a/Demo/metaclasses/Trace.py b/Demo/metaclasses/Trace.py index 69b9fab..97fda56 100644 --- a/Demo/metaclasses/Trace.py +++ b/Demo/metaclasses/Trace.py @@ -50,7 +50,7 @@ class TraceMetaClass: init = inst.__getattr__('__init__') except AttributeError: init = lambda: None - apply(init, args, kw) + init(*args, **kw) return inst __trace_output__ = None @@ -85,7 +85,7 @@ class NotTracingWrapper: self.func = func self.inst = inst def __call__(self, *args, **kw): - return apply(self.func, (self.inst,) + args, kw) + return self.func(self.inst, *args, **kw) class TracingWrapper(NotTracingWrapper): def __call__(self, *args, **kw): @@ -93,7 +93,7 @@ class TracingWrapper(NotTracingWrapper): "calling %s, inst=%s, args=%s, kw=%s", self.__name__, self.inst, args, kw) try: - rv = apply(self.func, (self.inst,) + args, kw) + rv = self.func(self.inst, *args, **kw) except: t, v, tb = sys.exc_info() self.inst.__trace_call__(self.inst.__trace_output__, diff --git a/Demo/pdist/RCSProxy.py b/Demo/pdist/RCSProxy.py index 87c65cc..ff3f0ce 100755 --- a/Demo/pdist/RCSProxy.py +++ b/Demo/pdist/RCSProxy.py @@ -186,7 +186,7 @@ def test(): if hasattr(proxy, what): attr = getattr(proxy, what) if callable(attr): - print apply(attr, tuple(sys.argv[2:])) + print attr(*sys.argv[2:]) else: print repr(attr) else: diff --git a/Demo/pdist/client.py b/Demo/pdist/client.py index 3e97d84..664c41b 100755 --- a/Demo/pdist/client.py +++ b/Demo/pdist/client.py @@ -132,12 +132,11 @@ from security import Security class SecureClient(Client, Security): def __init__(self, *args): - import string - apply(self._pre_init, args) + self._pre_init(*args) Security.__init__(self) self._wf.flush() line = self._rf.readline() - challenge = string.atoi(string.strip(line)) + challenge = int(line.strip()) response = self._encode_challenge(challenge) line = repr(long(response)) if line[-1] in 'Ll': line = line[:-1] diff --git a/Demo/pdist/server.py b/Demo/pdist/server.py index 01b3249..79afa8b 100755 --- a/Demo/pdist/server.py +++ b/Demo/pdist/server.py @@ -81,7 +81,7 @@ class Server: raise NameError, "illegal method name %s" % repr(methodname) else: method = getattr(self, methodname) - reply = (None, apply(method, args), id) + reply = (None, method(*args), id) except: reply = (sys.exc_info()[:2], id) if id < 0 and reply[:2] == (None, None): @@ -117,7 +117,7 @@ from security import Security class SecureServer(Server, Security): def __init__(self, *args): - apply(Server.__init__, (self,) + args) + Server.__init__(self, *args) Security.__init__(self) def _verify(self, conn, address): diff --git a/Demo/threads/Coroutine.py b/Demo/threads/Coroutine.py index 4cc65f7..10fa303 100644 --- a/Demo/threads/Coroutine.py +++ b/Demo/threads/Coroutine.py @@ -115,7 +115,7 @@ class Coroutine: if not self.killed: try: try: - apply(me.f, args) + me.f(*args) except Killed: pass finally: diff --git a/Demo/threads/Generator.py b/Demo/threads/Generator.py index a2713af..63bed9b 100644 --- a/Demo/threads/Generator.py +++ b/Demo/threads/Generator.py @@ -22,7 +22,7 @@ class Generator: self.putlock.acquire() if not self.killed: try: - apply(self.func, (self,) + self.args) + self.func(self, *self.args) except Killed: pass finally: diff --git a/Demo/threads/find.py b/Demo/threads/find.py index 7d5edc1..14148b8 100644 --- a/Demo/threads/find.py +++ b/Demo/threads/find.py @@ -17,7 +17,6 @@ import sys import getopt -import string import time import os from stat import * @@ -85,7 +84,7 @@ class WorkQ: if not job: break func, args = job - apply(func, args) + func(*args) self._donework() def run(self, nworkers): @@ -104,7 +103,7 @@ def main(): opts, args = getopt.getopt(sys.argv[1:], '-w:') for opt, arg in opts: if opt == '-w': - nworkers = string.atoi(arg) + nworkers = int(arg) if not args: args = [os.curdir] diff --git a/Demo/tix/tixwidgets.py b/Demo/tix/tixwidgets.py index de2e22e..bf7102a 100644 --- a/Demo/tix/tixwidgets.py +++ b/Demo/tix/tixwidgets.py @@ -71,8 +71,7 @@ class Demo: hm.add_checkbutton(label='BalloonHelp', underline=0, command=ToggleHelp, variable=self.useBalloons) # The trace variable option doesn't seem to work, instead I use 'command' - #apply(w.tk.call, ('trace', 'variable', self.useBalloons, 'w', - # ToggleHelp)) + #w.tk.call('trace', 'variable', self.useBalloons, 'w', ToggleHelp)) return w diff --git a/Demo/tkinter/guido/AttrDialog.py b/Demo/tkinter/guido/AttrDialog.py index 86333ad..9fa699e 100755 --- a/Demo/tkinter/guido/AttrDialog.py +++ b/Demo/tkinter/guido/AttrDialog.py @@ -155,8 +155,7 @@ class PackDialog(Dialog): def set(self, e=None): self.current = self.var.get() try: - apply(self.dialog.widget.pack, (), - {self.option: self.current}) + self.dialog.widget.pack(**{self.option: self.current}) except TclError, msg: print msg self.refresh() diff --git a/Demo/tkinter/guido/ManPage.py b/Demo/tkinter/guido/ManPage.py index 7d6fe00..911961e 100755 --- a/Demo/tkinter/guido/ManPage.py +++ b/Demo/tkinter/guido/ManPage.py @@ -22,7 +22,7 @@ class EditableManPage(ScrolledText): # Initialize instance def __init__(self, master=None, **cnf): # Initialize base class - apply(ScrolledText.__init__, (self, master), cnf) + ScrolledText.__init__(self, master, **cnf) # Define tags for formatting styles self.tag_config('X', underline=1) @@ -178,7 +178,7 @@ class ReadonlyManPage(EditableManPage): # Initialize instance def __init__(self, master=None, **cnf): cnf['state'] = DISABLED - apply(EditableManPage.__init__, (self, master), cnf) + EditableManPage.__init__(self, master, **cnf) # Alias ManPage = ReadonlyManPage diff --git a/Demo/tkinter/guido/ShellWindow.py b/Demo/tkinter/guido/ShellWindow.py index 609101b..6cdce0b 100755 --- a/Demo/tkinter/guido/ShellWindow.py +++ b/Demo/tkinter/guido/ShellWindow.py @@ -20,7 +20,7 @@ class ShellWindow(ScrolledText): args = string.split(shell) shell = args[0] - apply(ScrolledText.__init__, (self, master), cnf) + ScrolledText.__init__(self, master, **cnf) self.pos = '1.0' self.bind('<Return>', self.inputhandler) self.bind('<Control-c>', self.sigint) diff --git a/Demo/tkinter/guido/kill.py b/Demo/tkinter/guido/kill.py index e7df261..dd0dbf4 100755 --- a/Demo/tkinter/guido/kill.py +++ b/Demo/tkinter/guido/kill.py @@ -9,7 +9,7 @@ import os class BarButton(Menubutton): def __init__(self, master=None, **cnf): - apply(Menubutton.__init__, (self, master), cnf) + Menubutton.__init__(self, master, **cnf) self.pack(side=LEFT) self.menu = Menu(self, name='menu') self['menu'] = self.menu diff --git a/Demo/tkinter/guido/optionmenu.py b/Demo/tkinter/guido/optionmenu.py index be9d3ac..7365fa6 100644 --- a/Demo/tkinter/guido/optionmenu.py +++ b/Demo/tkinter/guido/optionmenu.py @@ -21,7 +21,7 @@ CHOICES = "Aah", "Bee", "Cee", "Dee", "Eff" var2 = StringVar() var2.set(CHOICES[0]) -menu2 = apply(OptionMenu, (root, var2) + tuple(CHOICES)) +menu2 = OptionMenu(root, var2, *CHOICES) menu2.pack() root.mainloop() diff --git a/Demo/tkinter/guido/sortvisu.py b/Demo/tkinter/guido/sortvisu.py index f18f2c1..3e4454f 100644 --- a/Demo/tkinter/guido/sortvisu.py +++ b/Demo/tkinter/guido/sortvisu.py @@ -523,8 +523,7 @@ class SortDemo: if self.size not in sizes: sizes.append(self.size) sizes.sort() - self.m_size = apply(OptionMenu, - (self.botleftframe, self.v_size) + tuple(sizes)) + self.m_size = OptionMenu(self.botleftframe, self.v_size, *sizes) self.m_size.pack(fill=X) self.v_speed = StringVar(self.master) diff --git a/Demo/tkinter/guido/svkill.py b/Demo/tkinter/guido/svkill.py index 69f7f3b..95f61b8 100755 --- a/Demo/tkinter/guido/svkill.py +++ b/Demo/tkinter/guido/svkill.py @@ -16,7 +16,7 @@ user = os.environ['LOGNAME'] class BarButton(Menubutton): def __init__(self, master=None, **cnf): - apply(Menubutton.__init__, (self, master), cnf) + Menubutton.__init__(self, master, **cnf) self.pack(side=LEFT) self.menu = Menu(self, name='menu') self['menu'] = self.menu @@ -61,7 +61,7 @@ class Kill(Frame): def do_1(self, e): self.kill(e.widget.get(e.widget.nearest(e.y))) def __init__(self, master=None, **cnf): - apply(Frame.__init__, (self, master), cnf) + Frame.__init__(self, master, **cnf) self.pack(expand=1, fill=BOTH) self.bar = Frame(self, name='bar', relief=RAISED, borderwidth=2) diff --git a/Demo/tkinter/matt/window-creation-w-location.py b/Demo/tkinter/matt/window-creation-w-location.py index 3f2b5b0..9f23bac 100644 --- a/Demo/tkinter/matt/window-creation-w-location.py +++ b/Demo/tkinter/matt/window-creation-w-location.py @@ -13,7 +13,7 @@ class QuitButton(Button): kwargs["text"] = "QUIT" if not kwargs.has_key("command"): kwargs["command"] = master.quit - apply(Button.__init__, (self, master) + args, kwargs) + Button.__init__(self, master, *args, **kwargs) class Test(Frame): def makeWindow(self, *args): |