[Tutor] Simple Question On A Method (in subclass)

Wayne Werner waynejwerner at gmail.com
Mon Oct 24 13:45:46 CEST 2011


On Sun, Oct 23, 2011 at 11:06 PM, Marc Tompkins <marc.tompkins at gmail.com>wrote:

> Things to remember:
> -you can get a value from a method, but you can't assign to it:
>     variable = object.method()
> but NOT
>     object.method() = variable
>

As a slight aside, you _can_ assign to the method name:

object.method = variable     #object.method is now whatever variable was

I'm not aware of any valid reason to do this, that is to say I don't know of
anything that you could do this way that you couldn't do another more
readable/maintainable way.

But I could be wrong!

HTH,
-Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111024/bf5627c0/attachment.html>


More information about the Tutor mailing list