[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code (original) (raw)
Terry Reedy tjreedy at udel.edu
Sat Jul 2 09:35:43 CEST 2005
- Previous message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Next message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Ralf W. Grosse-Kunstleve" <rwgk at cci.lbl.gov> wrote in message news:200507020319.j623JAUu311991 at boa.lbl.gov...
I'd also be happy with
def init(self, self.x, self.y, self.z): which wouldn't be too different from unpacking tuples
If you are willing to require that the args be passed as a tuple (extra pair of parens) I believe you could do
def __init__(s, args):
s.x, s.y, s.z = args
This even checks for correct number of actual args. I believe part of your underlying point is that you do not (usually) in this type of situation really need or want the args to be separately named locals since you just want to attach them to the instance.
(Way too late, may have made an error.)
Terry J. Reedy
- Previous message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Next message: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]