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
PyEcore has some unexpected (non-pythonic) behavior with EClass.behavior #80
Comments
If you like I'll submit a pull-request when I have a chance changing this to a decorator with arguments. I looked at behavior.py, and the change looks simple enough (famous last words). |
The dynamic case would then look like this fragment, if I understand things:
I also realize earlier I was confused - because you have the behavior module with the behavior decorator function within it. |
Well, now I see the
|
I took long enough to deal with this, but I added your proposition in Thanks again for the ticket and please accept my appologize for the delay of the answer/inclusion of your proposal. |
Minor issue, and I'm unclear what the motivation for this design is - why not just have behavior be available on EClass, or just have the decorator be separate from EClass.
This issue arises from the code sample in doc/source/user/advanced.rst that says
But, knowing python, I knew that importing
pyecore.behavior
as some name (behavior
) in the global namespace had nothing to do withbehavior
becoming available as a decorator on EClass.It is unexpected, to me, for an import to add methods or attributes to some class in some other package. The whole point of this is apparently to add "behavior" to EClass, in order to allow it to be used as a decorator, like:
But I looked at the code example, which said that "import pyecore.behavior" was needed, and knowing python thought to myself, that can't be true. Note that the "as behavior" is NOT needed, as my example changing it to "inattendu" demonstrated.
If you want a decorator for behavior, why not just have it. If it needs to have access to other information, such as some related class, just tell it. Then the code would become:
This would be completely equivalent:
For some information on decorators with arguments, one reference is Decorators with arguments
The text was updated successfully, but these errors were encountered: