Re: Parameter lists

2007-02-05 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Sun, 04 Feb 2007 17:45:04 +0100, Mizipzor wrote: > > >>Consider the following snippet of code: >> >>class Stats: >>def __init__(self, speed, maxHp, armor, strength, attackSpeed, imagePath): >>self.speed = speed >>self.maxHp = maxHp >>

Re: Parameter lists

2007-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2007 17:45:04 +0100, Mizipzor wrote: > Consider the following snippet of code: > > == > > class Stats: > def __init__(self, speed, maxHp, armor, strength, attackSpeed, imagePath): > self.speed = speed > self.maxHp = maxHp > self.

Re: Parameter lists

2007-02-04 Thread Jeffrey Froman
Mizipzor wrote: > class Stats: > def __init__(self, *li): > self.speed = li[0] > self.maxHp = li[1] > (...) > > Or maybe there is an even niftier way that lets me iterate through > them? Using keyword arguments instead of positional parameters makes this easy: >>> class

Re: Parameter lists

2007-02-04 Thread rzed
Mizipzor <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Consider the following snippet of code: > > == > > class Stats: > def __init__(self, speed, maxHp, armor, strength, > attackSpeed, imagePath): > self.speed = speed > self.maxHp = max

Re: Parameter lists

2007-02-04 Thread bearophileHUGS
Mizipzor > I dont like the looks of that code, there are many > function parameters to be sent in and if I were to add an attribute, i > would need to add it in three places. Add it to the function > parameters, add it to the class and assign it. > Is there a smoother way to do this? You may use s

Parameter lists

2007-02-04 Thread Mizipzor
Consider the following snippet of code: == class Stats: def __init__(self, speed, maxHp, armor, strength, attackSpeed, imagePath): self.speed = speed self.maxHp = maxHp self.armor = armor self.strength = strength self.attackSpeed