Skip to content

Conversation

@GuyHoozdis
Copy link
Contributor

A linter would yeild an error on the anti-pattern code. Even though it
is anti-pattern code, it should demonstrate best practices for
everything except the anti-pattern being demonstrated.

Although not 'k' in d and 'k' not in d ultimately produce the same
bytecode, the former is actually two operations and must be optimized to
produce identical bytecode to the latter.

The preferred syntax would be 'k' not in d - per the pep8/flake8
linter.

References:

A linter would yeild an error on the anti-pattern code.  Even though it
is anti-pattern code, it should demonstrate best practices for
everything except the anti-pattern being demonstrated.

Although `not 'k' in d` and `'k' not in d` ultimately produce the same
bytecode, the former is actually two operations and must be optimized to
produce identical bytecode to the latter.

The preferred syntax would be `'k' not in d` - per the pep8/flake8
linter.

References:

 - https://github.com/PyCQA/pycodestyle/blob/1.7.0/pep8.py#L1077-L1078
 - http://stackoverflow.com/questions/17659303/what-is-more-pythonic-for-not
@adewes
Copy link
Member

adewes commented Jul 26, 2016

great, thanks @GuyHoozdis !

@adewes adewes merged commit d5260f8 into quantifiedcode:master Jul 26, 2016
@GuyHoozdis
Copy link
Contributor Author

The Little Book of Python Anti-Patterns is a wonderful resource. It was my pleasure to read and to make this minor contribution. Hopefully, I will be able to contribute more in the future.

Until then...

@GuyHoozdis GuyHoozdis deleted the feature/e713-test-for-membershipt-should-be-not-in branch July 26, 2016 15:06
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

Successfully merging this pull request may close these issues.

2 participants