-
Notifications
You must be signed in to change notification settings - Fork 62
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
Dunder methods #43
Comments
I am surprised b. |
So patching the lexer to allow underscored identifiers within accent quotes is pretty straight forward. See: Vindaar/Nim@d047887 If promoting good Python interoperability is a goal of Nim, this would be nice to have I guess. I can see it opening a can of worms though, although all tests seem to pass on my machine. |
There's only one way to find out :) |
Please, PR it to Nim @Vindaar, I think it is useful |
Ok, so the alternatives are:
I'd go with 1 tbh, but I admit I'm not a day-to-day python user, so I might be missing smth. |
Closing this since no objections. Feel free to bring more arguments though. |
@yglukhov Hopefully we can reconsider this, because we can't define iter and next to implement a Python iterator without supporting the names of the magic methods. |
The magic/dunder methods rely on identifiers with underscores incompatible with Nim identifiers.
Below is an example of a common interaction with Python context managers where a slight workaround is needed to invoke such methods.
This works just fine, but it seems like this could be a spot for some convenience wrapper/convention for dealing with Python context managers. Any thoughts on anything nimpy might want to support?
The text was updated successfully, but these errors were encountered: