shannonhlo / pokemon-classification

3 stars 0 forks source link

Coding style conventions #4

Closed gavh3 closed 3 years ago

gavh3 commented 3 years ago

How do you guys like to style your code? For example, PEP 8 style guide is generally what I follow: https://www.python.org/dev/peps/pep-0008/

TLDR:

var_name # variable names should be lowercase, with underscores if it improves readability
function_name # function names should be lowercase, with underscores if it improves readability
ClassName # class names should use "CapWords" case
package # packages and modules should be lowercase, with underscores if it improves readability

# imports should be one per line
import os
import sys

# instead of
import os, sys

Thoughts?

nkumar97 commented 3 years ago

I like this, it's typically how i've been styling my code too didn't know there was a specific style guide for it lool

dmf95 commented 3 years ago

I also like this, and agreed with Nitish LOL. One thing I will advocate for is annotations on functions and for each section of code.

For example, here is a format I have been using lately - how do we feel about this?

# 1 Helper functions
#-----------------------------
# Brief: build helper functions to be referenced later in the code

# function #1: adds a suffix to a username
#-----------------------------
# input: a username in string format
# output: a username with a suffix as a string
def suffix_builder(x):...
     y = f'{x}@gmail.com'
     return y
gavh3 commented 3 years ago

I also like this, and agreed with Nitish LOL. One thing I will advocate for is annotations on functions and for each section of code.

For example, here is a format I have been using lately - how do we feel about this?

# 1 Helper functions
#-----------------------------
# Brief: build helper functions to be referenced later in the code

# function #1: adds a suffix to a username
#-----------------------------
# input: a username in string format
# output: a username with a suffix as a string
def suffix_builder(x):...
     y = f'{x}@gmail.com'
     return y

Agreed for the most part on annotating, my only comment about numbering each section is that ordering can get weird over time as we add more changes between multiple people.