i've been self coding in python for a while now but i never ever could learn how to structure my projects into proper structure. this is what i am doing right now
my_project/
src/
__init__.py
dog.py
animal.py
main.py
each script looks like this
# animal.py
class animal:
def __init__(self, kind):
self.kind = kind
if __name__=='__main__':
a=animal("mammal")
#dog.py
if __name__=='__main__':
from animal import animal
else:
from .animal import animal
class dog(animal):
def __init__(self, name, age):
super().__init__('Mammal')
self.name = name
self.age = age
if __name__=='__main__':
d=dog("Fido", 3)
#__init__.pyt
from .animal import *
from .dog import *
# main.py
import src
d=src.dog("Fido", 3)
My question is is this an at least ok way of structuring things, the imports in dog.py are extremelly ugly imho and i couldn't find any other way to be able to both run the dog.py itself as part of development below if name part and also being able to make this script import things correctly when i run stuff from outside the src/ directory (main.py)