A quick note before we begin, whilst this article specifically describes a way of writing cleaner and safer Win32 GDI code in Python, these same techniques could be applied to any corresponding API which requires manual resource management. A task came up recently which required utilising some old Win32 GDI APIs for a legacy application …