[Tutor] Uncallable class methods?
steve
lonetwin@yahoo.com
Tue, 12 Jun 2001 14:52:43 +0530
Hi all,
This here is a nice question vvvvvvvvv
> Quick question about the following piece of code:
> >>> class X:
>
> .. def y():
> .. print 'I am y of x.'
>
> Is there anyway that y can be invoked? My understanding is no, in which
> case, can anyone tell me why the interpreter doesn't complain about a c=
lass
> method being declared which does not have the minimum of one argument?
Well, here's how I see it as...I think it's a pretty good thing that pyt=
hon=20
complains when U try to use an "unbound" function, but does not when u de=
fine=20
it .....'cos by doing that I can ensure that these functions are to be us=
ed=20
"only" within the class itself.....kinda like a "private" function....if =
u=20
really do require to use something that u defined for the class but did n=
ot=20
mean an object of the class to use it, well define it outside the class a=
nd=20
make it available to the class by importing it.....else make it a "valid"=
=20
function of the class.
Like I said ealier....just my thoughts....I've never come across the need=
to=20
use an "unbound" funtion outside a class....but then again, I haven't yet=
=20
solved all the world's problems too.
Peace
Steve
--=20
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||=09
|||/\##|||||||||##/\||=09
|/ \#########/ \=09
|\ \#######/ /=09
||\____/#######\____/|=09
=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=09
Hello. Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
=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