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

Can't use a FlexEntity as the "kwargs" part of a call #12

Open
dobesv opened this issue Aug 31, 2016 · 1 comment
Open

Can't use a FlexEntity as the "kwargs" part of a call #12

dobesv opened this issue Aug 31, 2016 · 1 comment

Comments

@dobesv
Copy link

dobesv commented Aug 31, 2016

e.g.

>>> (lambda **args: args)(**FlexEntity(foo=1, bar=2))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: attribute of type 'NoneType' is not callable

The solution is to implement the keys() method:

>>> FlexEntity.keys = (lambda e: [key for key, value in e.iteritems()])
>>> (lambda **args: args)(**FlexEntity(foo=1, bar=2))
{'foo': 1, 'bar': 2}
@six8
Copy link
Collaborator

six8 commented Sep 1, 2016

Interesting. I guess I never considered that you could make ** work for other classes. I just assumed it only worked with dict.

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

2 participants