I had a dire need for some gradients, so I packaged your code into a class and added the radial option (here).
Some usage examples:
Linear gradient, left to right, adjusting the location of the color shift for best effect:
Gradient(['grey', 'black'], locations=[0.0, 0.6])
Radial gradient from center:
Gradient(['white', 'transparent'], radial=True, width=200, height=200)
Finer control available with the additional parameters, I can detail those if someone has a need - too late now for serious documentation.