Structure Projects
Simple Project:
One file for tiggering minimal functionality:
run.py
import constants as const
import helpers
# Triggering the entire project
# Do this by python run.py
def run():
primes = helpers.calculate_primes(start=const.START, finish=const.FINISH)
print(primes)
# Calling the run function:
if __name__ == '__main__':
run()
Functions and other such stuff in
helpers.py
import constants as const
# Functions that are going to help calculate prime numbers
def is_prime(num):
if num > 1:
for n in range(2, num):
if num % n != 0:
continue
else:
return False
return True
def calculate_primes(start, finish):
primes = []
for n in range(start, finish):
if is_prime(n) and not in c.SKIP_RANGE:
primes.append(n)
return primes
constants.py
are variables that do not change
# Useful variables that are going to be used
START = 1
FINISH = 100
SKIP_RANGE = range(20, 50)
Complex Project:
Folder
email
contains the email sending feature for the applicationFolder
prime_calculation
contains the prime calculation functionalityrun.py
is in the main folder and is responsible for starting up the project
Last updated