3 ms·
I worked on a million+ line Python project, here are some observations: * No duck typing * Document all input/output parameters to functions. * Avoid fancy m
by YZF 10y ago
I worked on a million+ line Python project, here are some observations:
* No duck typing
* Document all input/output parameters to functions.
* Avoid fancy meta-progamming.
* Try to break it up into smaller pieces with well defined interfaces that are ideally not pythonic. Think about the interfaces as something you'd potentially want other programming languages to be able to talk to.
* Don't use eval/exec or more generally don't pass Python code around.
In general as the scope of a module/unit gets larger you want to stick with simpler stuff. If the module/unit is small, the interface is small, and there are good tests around it, you can do anything you want inside that smaller bit.
[EDIT: These comments are mostly Python specific. On top of that you'd apply what you would in any other language, organize your code properly, consistent style throughout which in Python includes following the relevant standards PEP8, doing code reviews, tests etc. etc.]
- StavrosK 10y agoThis is pretty accurate. I'm also very excited about the new (optional) static typing, which should help a whole lot with maintainability. If possible (it probably is possible nowadays), use it, and lint your project with mypy. It will show you lots of potential problems with your code, and your interfaces will be much cleaner. Trying to make your parts as self-contained as possible is always a good idea.
- agumonkey 10y agoLots of people are going into typescript (es6 + types). I wonder how long before python gets the same. And when all languages merge into one. With a new '(universal . syntax).