Y
Hacker News
new
|
ask
|
show
|
jobs
by
a3n
3348 days ago
Suggestion: a short main() and if __name__ = ... for each file, serving as a demo/smoke test. It doesn't stop you from importing it as a module, and it's nice to see using code.
1 comments
felixhummel
3348 days ago
Along the same lines - use doctests maybe?
if __name__ == "__main__": import doctest doctest.testmod()
https://docs.python.org/3.5/library/doctest.html
link
a3n
3348 days ago
A great idea. But I'd also like to see an all-in-one-place dog and pony show, constructing it and using it right next to each other.
link
majke
3348 days ago
Agreed. Such code without decent doctests is close to useless. Also - try to get decent code coverage if you can.
link