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

Comparing to types directly in context.py #13

Open
mekarpeles opened this issue Feb 10, 2014 · 0 comments
Open

Comparing to types directly in context.py #13

mekarpeles opened this issue Feb 10, 2014 · 0 comments

Comments

@mekarpeles
Copy link

Context: Lines 141 - 156 in phantompy / phantompy / context.py on branch master, as of 444219e

Is there a reason why _type is compared to primitives using == rather than isinstance or is?

From PEP8 (http://www.python.org/dev/peps/pep-0008/#programming-recommendations), "Object type comparisons should always use isinstance() instead of comparing types directly."

def __new__(cls):
    def _make_getter(key, _type):
        def getter(self):
            if _type == bool:
                return  _type(lib.ph_context_get_boolean_config(key))
            elif _type == int:
                return _type(lib.ph_context_get_int_config(key))

        return getter

    def _make_setter(key, _type):
        def setter(self, value):
            if _type == int:
                lib.ph_context_set_int_config(key, int(value))
            elif _type == bool:
                lib.ph_context_set_boolean_config(key, int(value))
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