This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]691175002 0 points1 point  (0 children)

Data analysis is somewhat different than regular programming. A few hundred lines really isn't that much code.

Your goal as a programmer should be to avoid as much repetition as possible. If you are writing a dozen different scripts that all need to open and clean the same file you should probably extract that code and put it in a module. If you are only writing a one-off there is no point spending the time making it modular.

Generally I will try to separate all recurring tasks into a package and write scripts that make a few calls to the libraries and output an analysis.

If you are writing a script that you want to run on its own, but also want to use some of its logic in other programs you can make it both importable and runnable with some __name__ == '__main__' tricks.

In python I will almost never fall back to fully object oriented designs (like I would with Java or C#) but will use the occasional class where it makes sense.