[Tutor] Default function in a class ... is it possible???
runsun
runsun@bilbo.bio.purdue.edu
Tue, 27 Aug 2002 21:14:21 -0500
Hi I wanna know if a class can have a default function. For example,
class myclass:
def __init__(self): pass
def quote(self, aText):
return "[" + aText + "]"
c =3D myclass()
print c.quote('data') =3D=3D=3D> will print "[data]"
Is there any way to make the following possible:
print c('data') =3D=3D=3D=3D=3D> also print "[data]"
means, making the function "quote()" as the default function of class
"myclass"
Thx in advance.
pan
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
~~ Be like water, be shapeless ~~
Runsun Pan, PhD, 773-834-3965
Ecology & Evolution, U of Chicago
------------------------------------------------------
=ABn=A4=E8=A7=D6=B3=F8=BA=F4=B8=F4=AA=A9 http://snews.8k.com/
=A4=E5=A4=C6=BD=D7=BE=C2 http://taiwantp.net/cgi/roadbbs.pl?board_id=3D7
=ACF=B8g=BD=D7=BE=C2 http://taiwantp.net/cgi/roadbbs.pl?board_id=3D3
=BBP=B4C=C5=E9=B9=EF=A7=DC http://taiwantp.net/cgi/roadbbs.pl?board_id=3D=
2
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D