-
Notifications
You must be signed in to change notification settings - Fork 83
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
Python3 Support #87
Merged
Merged
Python3 Support #87
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Standard library imports should go first. - Remove unused or duplicate imports.
- expr == False -> not expr - expr == True -> expr (or expr is True, if the type isn't clear). - not x in y => x not in y - not x == "1" => x != "1" - omit range default - 'if not x or not y: pass else: z' => 'if x and y: z' - str.__len__ => len - x > 1 and x < 10 => 1 < x < 10 - not x > y => x <= y - if x: if y: if z: _ => if x and y and x: _ - BUGFIX: "a" and "b" in f => all(i in f for i in ["a","b"]) - BUGFIX: .lower => .lower()
- defaultdict to avoid initialising every entry up front - Use struct.calcsize instead of copying the values. - if x == 0: y = False: else y = True => y = bool(x) - list[len(list)-1] => list[-1] - math.pow(256, 1) => 0x08 etc. - x = bytearray(); x.append(y); x.append(z) => x = bytearray([y, z]) - value = x; return value => return x
- Create dicts at compile time. - Use startswith as it's less error prone. - Add some FIXMEs. - Make dict at compile time. - Use enumerate. - Lift sum out of if blocks.
It's much easier to use and it didn't change from python2 to python3. I can't easily test PacketGen, though, but it seems to be unused.
We were passing a string where an integer port number was expected. Add a cast.
This code shouldn't really be relying on division, but change it to return an integer anyway.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request to help with testing