In fact you may even find there's an example in the documentation.