Re: Instance attributes vs method arguments

2008-11-26 Thread Aahz
In article [EMAIL PROTECTED], M.-A. Lemburg [EMAIL PROTECTED] wrote: It is always good practice to provide default values for instance variables in the class definition, both to enhance readability and to allow adding documentation regarding the variables, e.g. Actually, my company uses an

Re: Instance attributes vs method arguments

2008-11-25 Thread Marc 'BlackJack' Rintsch
On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: Is it better to do this: class Class_a(): def __init__(self, args): self.a = args.a self.b = args.b self.c = args.c self.d = args.d def method_ab(self):

Re: Instance attributes vs method arguments

2008-11-25 Thread bieffe62
On 25 Nov, 08:27, John O'Hagan [EMAIL PROTECTED] wrote: Is it better to do this: class Class_a():         def __init__(self, args):                 self.a = args.a                         self.b = args.b                 self.c = args.c                 self.d = args.d         def

Re: Instance attributes vs method arguments

2008-11-25 Thread M.-A. Lemburg
On 2008-11-25 08:27, John O'Hagan wrote: Is it better to do this: class Class_a(): def __init__(self, args): self.a = args.a self.b = args.b self.c = args.c self.d = args.d def method_ab(self):

Re: Instance attributes vs method arguments

2008-11-25 Thread Rafe
snip It is always good practice to provide default values for instance variables in the class definition, both to enhance readability and to allow adding documentation regarding the variables, e.g. class Class_a:    # Foo bar    a = None    # Foo baz    b = None snip Those are not

Re: Instance attributes vs method arguments

2008-11-25 Thread John O'Hagan
On Tue, 25 Nov 2008, Marc 'BlackJack' Rintsch wrote: On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: Is it better to do this: class Class_a(): def __init__(self, args): self.a = args.a self.b = args.b self.c = args.c

Re: Instance attributes vs method arguments

2008-11-25 Thread Marc 'BlackJack' Rintsch
On Tue, 25 Nov 2008 10:48:01 +, John O'Hagan wrote: On Tue, 25 Nov 2008, Marc 'BlackJack' Rintsch wrote: On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: Is it better to do this: class Class_a(): def __init__(self, args): self.a = args.a self.b =

Re: Instance attributes vs method arguments

2008-11-25 Thread Rafe
On Nov 25, 5:48 pm, John O'Hagan [EMAIL PROTECTED] wrote: On Tue, 25 Nov 2008, Marc 'BlackJack' Rintsch wrote: On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: Is it better to do this: class Class_a():       def __init__(self, args):               self.a = args.a          

Re: Instance attributes vs method arguments

2008-11-25 Thread Bruno Desthuilliers
M.-A. Lemburg a écrit : (snip) It is always good practice to provide default values for instance variables in the class definition, both to enhance readability and to allow adding documentation regarding the variables, e.g. Your opinion. As far as I'm concerned, using class variables this way

Re: Instance attributes vs method arguments

2008-11-25 Thread John O'Hagan
On Tue, 25 Nov 2008, Rafe wrote: On Nov 25, 5:48 pm, John O'Hagan [EMAIL PROTECTED] wrote: On Tue, 25 Nov 2008, Marc 'BlackJack' Rintsch wrote: On Tue, 25 Nov 2008 07:27:41 +, John O'Hagan wrote: Is it better to do this: class Class_a():       def __init__(self, args):

Re: Instance attributes vs method arguments

2008-11-25 Thread George Sakkis
On Nov 25, 8:49 pm, John O'Hagan [EMAIL PROTECTED] wrote: is there an difference in efficiency (for large enough number of methods and arguments) between a) passing all arguments to __init__() and accessing them via self within individual methods: class = Class(all_class_args)

Re: Instance attributes vs method arguments

2008-11-25 Thread Ben Finney
John O'Hagan [EMAIL PROTECTED] writes: insofar as one is only interested in accessing methods, is there an difference in efficiency (for large enough number of methods and arguments) between a) passing all arguments to __init__() and accessing them via self within individual methods:

Re: Instance attributes vs method arguments

2008-11-25 Thread Steven D'Aprano
On Tue, 25 Nov 2008 10:21:18 +0100, M.-A. Lemburg wrote: It is always good practice to provide default values for instance variables in the class definition, both to enhance readability and to allow adding documentation regarding the variables, e.g. class Class_a: # Foo bar a =

Re: Instance attributes vs method arguments

2008-11-25 Thread John O'Hagan
On Wed, 26 Nov 2008, Ben Finney wrote: John O'Hagan [EMAIL PROTECTED] writes: insofar as one is only interested in accessing methods, is there an difference in efficiency (for large enough number of methods and arguments) between a) passing all arguments to __init__() and accessing them

Instance attributes vs method arguments

2008-11-24 Thread John O'Hagan
Is it better to do this: class Class_a(): def __init__(self, args): self.a = args.a self.b = args.b self.c = args.c self.d = args.d def method_ab(self): return self.a + self.b def