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 can not take self and instance #47

Open
coldfix opened this issue May 28, 2014 · 0 comments
Open

**kwargs can not take self and instance #47

coldfix opened this issue May 28, 2014 · 0 comments

Comments

@coldfix
Copy link
Contributor

coldfix commented May 28, 2014

Consider the following example:

from obsub import event

class Foo(object):

    @event
    def bar(this, self):
        pass

    @event
    def baz(self, instance):
        pass

foo = Foo()

foo.bar(1)                  # works fine
foo.bar(self=1)             # TypeError

Foo.baz(foo, 1)             # works fine
Foo.baz(foo, instance=1)    # TypeError

The reason for this behaviour is obvious: obsub uses normal python arguments named instance and self in the wrapper functions, because python syntax doesn't allow for positional-only parameters. The fix is easy: make the signature of those functions (*args, **kwargs) and extract the self/instance parameter as the first parameter from *args.

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