Skip to content
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

kwargs on constructor #30

Closed
atsepkov opened this issue Dec 22, 2014 · 0 comments
Closed

kwargs on constructor #30

atsepkov opened this issue Dec 22, 2014 · 0 comments

Comments

@atsepkov
Copy link
Owner

The following code:

class test:
    @kwargs
    def __init__(self, a=100, b=200, c=300):
        print(a, b, c)

will compile into:

function test(a, b, c){
    var self = this;
    if (typeof a === "undefined") a = 100;
    if (typeof b === "undefined") b = 200;
    if (typeof c === "undefined") c = 300;
    _$rapyd$_print(a, b, c);
};
test.prototype.__init__ = kwargs(test.prototype.__init__);

Since init doesn't exist, it will break. I'd need to test this further to see if a passthrough of regular constructor through kwargs would work or would introduce other problems with isinstance() and inheritance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant