-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic procedure including a sub-class of TimeDelta #61
Comments
Thanks, indeed, the But in your case, you actually want to override the inherited operator with a new procedure. Certainly valid. To be honest, I don't know what the standard says about this, but I'd think that you should be able to override the inherited operator with a new one. Can you please post the code for In the meantime I will try to reproduce this in a minimal example. |
I appreciate your reply and I apologize much longer post. The implementation of
Test case is:
Output is:
I'm afraid that my current solution has to modify YOUR module:
Is there any smarter way to overload the operator? |
Hi Daisuke, Sorry about the delay with this. I agree with your conclusion--because the operators are defined as type-bound methods rather than regular procedures, they require The solution you propose would work for your use case, however it would break the use case of extended I can't think of any way to make both functionalities work with the same code, however if I do I will write here. I see that you have two options:
|
I faced a problem with a sub-class of
timedelta
.I defined a generic procedure name for
operator(+)
(as below, can be compiled),but the program executes the operator for
TimeDelta
, not forRelativeDelta
.One possible reason is
class
in the original datetime_plus_timedelta function.While
type(timedelta)
indicates only timedelta class,class(timedelta)
does sub-classes in addition to timedelta class.Could you update the attribute from
class
totype
in non-method procedures?Or what can I do for overloading of such a function?
I will appreciate your help with this issue.
The text was updated successfully, but these errors were encountered: