How can I use a Python class decorator in Rust code? #3537
Unanswered
silvanocerza
asked this question in
Questions
Replies: 1 comment 1 reply
-
I think we would need to implement this as a new |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a library written in Python that declares a decorator for classes. Something similar to this:
And it can be used like this:
So it overwrites the original definition of the
Whatever
class with a new one, containing some new fields, methods, etc.I know I can call Python functions in Rust, but is it possible to use this kind of decorator in Rust given that it overwrites the class definition?
My intention would be declaring a Python class in Rust like so:
And decorate it in Rust using
decorator
defined in Python. I tried this and it obviously doesn't work for several reasons.Is there a way to make this work or should I just rewrite the decorator in Rust?
Another alternative I tried is to wrap the class in Python after it's imported as this seems to work, but it's a bit more annoying.
Beta Was this translation helpful? Give feedback.
All reactions