Everything here is assuming Python as the language of choice:
- For scripts that send email, check to make sure the list of mail receivers is up-to-date.
- Look for those nasty embedded IP addresses and replace them with DNS names.
- Change from old-style open(FILE)/close(FILE) constructs to with open(FILE) as f constructs.
- Get rid of "pickles" for persistent structured data storage. Pickles are a form of native Python object serialization that are quick and convenient, but have a lot of potential problems. I've mostly used Python's native SQLite3 library to store data in simple persistent databases, but occasionally I just use plain text files.
- Look for repetitive code in the main script logic and try to move it into functions or classes where possible. For example, I had several scripts that were building email reports via clunky string concatenation, so I created a Report class that knows how to append to itself and do simple formatting.
- Remove unused module imports (that were usually there for debugging).
- Standardize module imports, declaration of constants, etc.
- Add more comments!
- Remove old code that was commented out for whatever reason.
- Look for places where I was creating huge lists in memory and try to figure out a way to reduce memory consumption with generators.
- Change to new-style string formatting.
- Write some tests, particularly for log parsers.
- Migrate from optparse to argparse for handling CLI flags.
- Migrate to Python 3.
1 comment:
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog.
Post a Comment