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

Environment class should implement __contains__ #50

Closed
christarnowski opened this issue Jun 8, 2011 · 0 comments
Closed

Environment class should implement __contains__ #50

christarnowski opened this issue Jun 8, 2011 · 0 comments

Comments

@christarnowski
Copy link
Contributor

Since webassets.Environment already implements magic methods such as __getitem__, it would be nice if the class provided __contains__ as well:

def __contains__(self, name):
    return name in self._named_bundles

This small feature comes in handy when iron-proofing against typos; it's also much more elegant than try...except KeyError: block.

Thanks!

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