Python

Some Python “Best Practices”

Python Logo As I have said before, I don’t believe their are truly “best practices”, sometimes there are “best known practices”, or “best known practices for a given context”.    But, there are often times when it is clear something is a bad practice.  And through the school of hard knocks, I’ve learned from attempting some practices that I thought were good, but turned out to be bad.  So here is what I have learned.

Read More →

Python Script to Automate Refreshing an Excel Spreadsheet

Excel Logo Plus Python LogoOften I run into situations where it makes sense to do analysis of a lot of database data in an Excel spreadsheet, but due to the amount of processing the spreadsheet requires when updating, it takes a long time for the spreadsheet to “Refresh All”.

One solution to this problem is to automate the spreadsheet so it refreshes every night.  The following is a small Python script that can do this using the Python for Windows Extension:

Read More →

Quick Guide to Writing “Cross-Versional” Python Code

Python LogoWhile Carleton College has a good guide about the differences that new students will likely see between the two, and there is an excellent blog article about why Python 3 hasn’t been more widely adopted, and the official Python site tries to explain the differences between the two versions; I have not been able to find any guides on how to write code that will automatically work in Python 3.x and the latest version of 2.x.   This is surprising, because one of the ways to get past the “gravity” of Python 2, is for people to learn to code in a manner that works for both 2 & 3.  So I decided to write a short guide myself.

Read More →