Simple question on Parameters...
Will McGugan
news at NOwillmcguganSPAM.com
Wed Dec 28 16:00:44 EST 2005
KraftDiner wrote:
> 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?
> Like should these be simple lists or should they be structures or
> classes...
You could define a class for the r, g, b, a values, or just use tuples
thusly..
def renderABezierPath(self, path, closePath=True, outlineColor=(1.0,
1.0, 1.0, 1.0), fillColor=(0.0, 0.0, 0.0, 0.25)):
It all depends on what you find the most elegant solution. Im guessing
you will use color values a lot, so I would recommend writing a simple
class. Its also more natural to refer to the components of the color by
name, rather than an index to the tuple.
Will McGugan
--
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in
"jvyy*jvyyzpthtna^pbz")
More information about the Python-list
mailing list