Last active
October 20, 2017 15:32
-
-
Save pathunstrom/ceca1fdf24250d256133c83cfc56c876 to your computer and use it in GitHub Desktop.
Organize python code
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
"""Everything should be alphabetical in it's group.""" | |
# Group imports by where they come from | |
# Standard Lib | |
import os | |
# PyPI/third party | |
import requests | |
# Local | |
import my_script | |
# Classes at the top | |
class AClass: | |
pass | |
class BClass: | |
pass | |
# Functions at the bottom | |
def a_func(): | |
pass | |
def a_wrapper(func): | |
def the_wrapper(): | |
return func() | |
def b_func(): | |
pass | |
def main(): | |
a_func() | |
b_func() | |
z_func() | |
@a_wrapper | |
def z_func(): | |
pass | |
# If you're making your script executable, this goes last. | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment