I’ve been writing some GPIO control stuff recently using a few different languages and tonight it was the turn of python.
Now from using different languages I’ve grown accustomed to using the BCM references for the GPIO pins. However as some of you may know, these differ slightly between Rev1 and Rev2 of the boards so it is important to ensure your code matches and is easily adapted for the board you are using.
An easy solution is simply to use a define for each and edit the code accordingly. But for python I’d often heard it suggested to automatically detect the revision of the board, which seems very sensible to me.