This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Michael.Gilbert
Recipients Michael.Gilbert
Date 2010-07-28.17:56:53
SpamBayes Score 0.008872247
Marked as misclassified No
Message-id <1280339816.95.0.28348031653.issue9401@psf.upfronthosting.co.za>
In-reply-to
Content
in order to make overrides simpler, and more obvious to average developers, it would be very useful to automatically call the forward operations (e.g. __mul__) when the reverse operations (e.g. __rmul__) are NotImplemented.  

i spent quite a bit of time trying to discover why x*3 worked (where x is a class that i created with a __mul__ method); whereas 3*x wouldn't. this feature would really help since in most applications the same behavior is expected from forward and reverse operations.

for now, i am content with doing this manually, but it would be nice if it were automated.  all of my reverse operations just do:

    def __rmul__( self , other ):
        return self.__mul__( other )

where i manually check the type of other in the forward operation, and then handle it appropriately.

thanks for considering this.

best wishes,
mike
History
Date User Action Args
2010-07-28 17:56:57Michael.Gilbertsetrecipients: + Michael.Gilbert
2010-07-28 17:56:56Michael.Gilbertsetmessageid: <1280339816.95.0.28348031653.issue9401@psf.upfronthosting.co.za>
2010-07-28 17:56:54Michael.Gilbertlinkissue9401 messages
2010-07-28 17:56:54Michael.Gilbertcreate