Simple question on Parameters...

Lawrence Oluyede raims at dot.com
Wed Dec 28 15:48:50 EST 2005


Il 2005-12-28, KraftDiner <bobrien18 at yahoo.com> ha scritto:
> I have defined a method as follows:
>
> def renderABezierPath(self, path, closePath=True, r=1.0, g=1.0, b=1.0,
> a=1.0, fr=0.0, fg=0.0, fb=0.0, fa=.25):
>
> Now wouldn't it be simpler if it was:
>
> def renderABezierPath(self, path, closePath=True, outlineColor,
> fillColor):
>
> But how do you set default vaules for outlineColor and fillColors?

You can make renderABezierPath like this:

def renderABezierPath(self, path, closePath=True,
    outlineColor=(1.0, 1.0, 1.0, 1.0), fillColor=(0.0, 0.0, 0.0, 0.25)):

and in the body you unpack the tuples


-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"



More information about the Python-list mailing list