FW: [Tutor] Uncallable class methods?

Andrew Wilkins toodles@yifan.net
Wed, 13 Jun 2001 15:19:35 +0800


Sorry Roeland!

> -----Original Message-----
> From: Andrew Wilkins [mailto:toodles@yifan.net]
> Sent: Tuesday, 12 June 2001 10:12 PM
> To: Roeland Rengelink
> Subject: RE: [Tutor] Uncallable class methods?
>
>
> <schnip/>
>
> > > 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 class method being declared which does not have
> > the minimum of one argument?
> > >
>
> Okey dokey I just thought I'd give another answer to the
> question, which also has the same useful nature of any of them *grin*
>
> import new
>
> class X:
>  def y():
>   print 'I am y of x'
>
> func=new.function(X.y.func_code,X.y.func_globals)
>
> It doesn't look as pretty as Roeland's IMO, but I felt like
> playing with the 'new' module =)
>
> Andrew Wilkins