Re: assigning values in __init__

2006-11-09 Thread Antoon Pardon
On 2006-11-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 09 Nov 2006 10:36:07 +, Antoon Pardon wrote: > >> On 2006-11-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >>> On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote: >>> John Salerno <[EMAIL PROTECTED]> writes: >

Re: assigning values in __init__

2006-11-09 Thread Steve Holden
Steven D'Aprano wrote: > On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote: > >> John Salerno <[EMAIL PROTECTED]> writes: >> >>> Ben Finney wrote: If you pass a *mapping* of the "I-might-want-to-add-more-in-the-future" values, then you get both explicit *and* expandable, without

Re: assigning values in __init__

2006-11-09 Thread Steven D'Aprano
On Thu, 09 Nov 2006 10:36:07 +, Antoon Pardon wrote: > On 2006-11-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote: >> >>> John Salerno <[EMAIL PROTECTED]> writes: >>> Ben Finney wrote: > If you pass a *mapping* of the > "I-

Re: assigning values in __init__

2006-11-09 Thread Antoon Pardon
On 2006-11-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote: > >> John Salerno <[EMAIL PROTECTED]> writes: >> >>> Ben Finney wrote: >>> > If you pass a *mapping* of the >>> > "I-might-want-to-add-more-in-the-future" values, then you get both >>>

Re: assigning values in __init__

2006-11-09 Thread Steven D'Aprano
On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote: > John Salerno <[EMAIL PROTECTED]> writes: > >> Ben Finney wrote: >> > If you pass a *mapping* of the >> > "I-might-want-to-add-more-in-the-future" values, then you get both >> > explicit *and* expandable, without an arbitrary unneeded sequenc

Re: assigning values in __init__

2006-11-08 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Ben Finney wrote: > > If you pass a *mapping* of the > > "I-might-want-to-add-more-in-the-future" values, then you get both > > explicit *and* expandable, without an arbitrary unneeded sequence. > > Do you mean by using the **kwargs parameter? No. I mean

Re: assigning values in __init__

2006-11-08 Thread Steven D'Aprano
On Wed, 08 Nov 2006 10:55:57 -0500, John Salerno wrote: > Ben Finney wrote: >> John Salerno <[EMAIL PROTECTED]> writes: >> >>> But I do like Steve's suggestion that it's better to be explicit >>> about each attribute, instead of just accepting a list of numbers >>> (but I can't help but feel that

Re: assigning values in __init__

2006-11-08 Thread John Salerno
Ben Finney wrote: > John Salerno <[EMAIL PROTECTED]> writes: > >> But I do like Steve's suggestion that it's better to be explicit >> about each attribute, instead of just accepting a list of numbers >> (but I can't help but feel that for some reason this is better, >> because it's more general).

Re: assigning values in __init__

2006-11-07 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > But I do like Steve's suggestion that it's better to be explicit > about each attribute, instead of just accepting a list of numbers > (but I can't help but feel that for some reason this is better, > because it's more general). If you pass a *mapping* o

Re: assigning values in __init__

2006-11-07 Thread John Salerno
John Salerno wrote: > Is this a good way to assign the values to the different attributes? > Should 'stats' be a list/tuple (like this), or should I do *stats instead? Thanks guys! The main suggestion seems to be to use setattr(), so I might give that a try. But I do like Steve's suggestion tha

Re: assigning values in __init__

2006-11-07 Thread Nick Craig-Wood
Larry Bates <[EMAIL PROTECTED]> wrote: > John Salerno wrote: > > Let's say I'm making a game and I have this base class: > > > > class Character(object): > > > > def __init__(self, name, stats): > > self.name = name > > self.strength = stats[0] > > self.dexterity = st

Re: assigning values in __init__

2006-11-06 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] > self.intelligenc

Re: assigning values in __init__

2006-11-06 Thread Steven D'Aprano
On Mon, 06 Nov 2006 16:57:58 -0500, John Salerno wrote: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] >

Re: assigning values in __init__

2006-11-06 Thread Steve Holden
John Salerno wrote: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] > self.intelligence = stats[2] >

Re: assigning values in __init__

2006-11-06 Thread Gerard Flanagan
John Salerno wrote: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] > self.intelligence = stats[2] >

Re: assigning values in __init__

2006-11-06 Thread Larry Bates
John Salerno wrote: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] > self.intelligence = stats[2] > se

assigning values in __init__

2006-11-06 Thread John Salerno
Let's say I'm making a game and I have this base class: class Character(object): def __init__(self, name, stats): self.name = name self.strength = stats[0] self.dexterity = stats[1] self.intelligence = stats[2] self.luck = stats[3] Is this a good