noob question: "TypeError" wrong number of args
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed May 3 16:57:23 EDT 2006
In <TFR5g.66612$F_3.16905 at newssvr29.news.prodigy.net>, Edward Elliott
wrote:
> I can prove that assertion too: make a simple text processor that reads
> Python source code and outputs the same source code with only one change:
> insert the string 'self" as the first parameter of every "def somemethod".
> Next run the output source code with the normal Python interpreter.
> Everything functions *exactly* as before because the code is *exactly* the
> same as what you would have written if you'd put the 'self's in there
> manually. Now make the Python interpreter invoke this text processor as
> the first step in processing source code. Voila, python + implicit self.
Okay, let's start with writing a simple text processor for this little
mess::
def b(c):
def d(r, *s, **t):
print '***'
c(r, *s, **t)
return d
class A:
@b
def a(x, y, z):
print y, z
x.e(23)
def e(u, v):
print u, v
class B:
def e(v, w):
print 'spam', v, w
A.e = e
x = A()
x.a('answer', 42)
e('eric', 'viking')
A.a(x, 'ham', 'eggs')
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list