Skip to content

Separating platform specific code

pepijndevos edited this page Sep 13, 2010 · 1 revision

So you only deal with platform X? I’ve some good news for you!

It is now incredibly easy to take out only the parts you need.

All you need is base.py and the code for the platform you need, mac.py for example.

Normally you’d import pymouse, and __init__.py would decide for you which platform to include, now you can just import mac.py directly and mac.py will pull the general stuff from base.py.

This is also great if you want to run for example the X11 code on Windows with Cygwin.

>>> from pymouse.mac import PyMouse
>>> p = PyMouse()
>>> p.click(200, 200)
Clone this wiki locally