[Tutor] Don't understand this class/constructor call syntax
dave
dave at csc.lsu.edu
Fri Jul 29 00:18:17 CEST 2011
Yes that is roughly what I meant. GNU Radio uses a lot of sub-classing--if
this is the correct term. For example all blocks inherit hier_block2 which
has methods such as connect for connecting two blocks together. I wondered if
the instance named self wasn't being passed as a replacement for the implicit
self parameter rather than in place of the pass_as_USRP=True parameter.
Steven D'Aprano also replied on this subject and if I understand him, then it
would require a special syntax that is not present in the GNU Radio code.
Dave
On Mon, 25 Jul 2011 08:08:54 +0100, Alan Gauld wrote
> dave wrote:
> > Is it even possible to replace the implicit self argument of the initializer
> > by passing something else? If so, what would be the syntax.
>
> Im not sure this is what you mean but...
>
> When you call a method on an object like:
>
> class MyClass:
> def aMethod(self,spam): pass
>
> anObject= MyClass()
> anObject.aMethod(42)
>
> You could replace the last line with:
>
> MyClass.aMethod(anObject, 42)
>
> This explicitly specifies the value of self in aMethod()
>
> So you could in theory pass any object into the method,
> although in most cases it would result in an error.
>
> Is that what you mean?
>
> Alan G.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list