> I learned python so that if I were to put in 0.9, it'd decrease red by 10%.> > The way this function needs to be written, -0.1 decreases red by 10% It sounds like you have something like ... def f1(color, redchange=0, bluechange=0, greenchange=0): # some code here to make the changes return modified_color calling it like ... >>> c = Color(red=200, blue=100, green=50)>>> c(200, 100, 50)>>> f1(c, >>> redchange=0.9)(180, 100, 50) but what you want is ... >>> f1a(c, redchange=-0.1)(180, 100, 50)
Maybe, since you already have a function that works, youcould write f1a as a function that calls f1 as a helper, usingmodified parameters. def f1a(color, redchange=0, bluechange=0, greenchange=0): # some code to modify the parameters to fit your function f1 return f1(color, modredchange, modbluechange, modgreenchange) So... we just need some code to convert 0.9 to -0.1 (and weneed to think about other possible values that could be sentto f1 and what f1a would want in the same situation.) There's a very simple way to convert 0.9 to -0.1 but I'm notsure that's what you want. Would you also want: >>> f1(c, redchange=0.5)(100, 100, 50)>>> f1a(c, redchange=-0.5)(100, 100, 50) How about ... >>> f1(c, redchange=0)(0, 100, 50)>>> f1a(c, redchange=-1.0)(0, 100, 50) Or ... >>> f1(c, redchange=1.2)(240, 100, 50)>>> f1a(c, redchange=0.2)(240, 100, 50) ? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor