Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Ralf W. Grosse-Kunstleve
Aahz wrote: > This is off-topic for python-dev. Please take it to comp.lang.python. > (It's not immediately obvious that this is off-topic, I know, but please > take my word for it.) Done: http://mail.python.org/pipermail/python-list/2005-July/288292.html Sorry for creating so much noise he

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Terry Reedy
"Ralf W. Grosse-Kunstleve" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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 (ext

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Josiah Carlson
"Ralf W. Grosse-Kunstleve" <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > Now, don't get me wrong, definining __slots__ can be a pain in the > > tookus, but with a proper metaclass, that metaclass can define the > > __slots__ attribute based on the argument list for __init__(). > > > > Th

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-02 Thread Reinhold Birkenfeld
Nick Coghlan wrote: [...] > If the right hand side of 'as' permitted the same forms as are going > to be permitted for the 'as' clause in 'with' statements, then Ralf's > situation could be handled via: > >def __init__(self as s, x as s.x, y as s.y, z as s.z): > pass > > Essentially

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Anthony Baxter
On Saturday 02 July 2005 08:59, Ralf W. Grosse-Kunstleve wrote: > I hate it, and every time I show this to a Python newcomer I get that > skeptic look. How about this for a change? > > class grouping: > > def __init__(self, .x, .y, .z): > pass -1. Syntax should not look like grit

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Aahz
On Fri, Jul 01, 2005, Ralf W. Grosse-Kunstleve wrote: > > I often find myself writing: > > class grouping: > > def __init__(self, x, y, z): > self.x = x > self.y = y > self.z = z > > I hate it, and every time I show this to a Python newcomer I get that > sk

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Nick Coghlan
Ralf W. Grosse-Kunstleve wrote: > I know enhancing the syntax is work, but shouldn't a syntax leading to > less code clutter be the higher value? IMO a long-term gain counts for > much more than avoiding a one-time investment implementing a useful > feature. Take, for example, the syntax enhancemen

[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Ralf W. Grosse-Kunstleve
Josiah Carlson wrote: > Now, don't get me wrong, definining __slots__ can be a pain in the > tookus, but with a proper metaclass, that metaclass can define the > __slots__ attribute based on the argument list for __init__(). > > There you go. Where? The meta-class idea sounds interesting. Could y

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: > Jp Calderone wrote: > > If you use vars(self).update(locals()), it even looks halfway > > pleasant ;) I'm not sure what python-dev's current opinion of > > vars(obj) is though (I'm hoping someone'll tell me). > > > > Of course, both of these fall over fo

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Ralf W. Grosse-Kunstleve
Jp Calderone wrote: > If you use vars(self).update(locals()), it even looks halfway > pleasant ;) I'm not sure what python-dev's current opinion of > vars(obj) is though (I'm hoping someone'll tell me). http://docs.python.org/lib/built-in-funcs.html#l2h-76 is pretty clear: vars([object]) W

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Nick Coghlan
Jp Calderone wrote: > If you use vars(self).update(locals()), it even looks halfway > pleasant ;) I'm not sure what python-dev's current opinion of > vars(obj) is though (I'm hoping someone'll tell me). > > Of course, both of these fall over for __slots__'ful classes. It'd > be nice if there wer

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Ralf W. Grosse-Kunstleve
I am happy to see that others agree we need something better than self.x=x; self.y=y; self.z=z. Phillip J. Eby wrote: >class grouping: >def __init__(self, x, y, z): >initialize(self, locals()) Been there (older code): http://phenix-online.org/cctbx_sources/scitbx/scitbx

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Jp Calderone
On Fri, 01 Jul 2005 19:22:20 -0400, "Phillip J. Eby" <[EMAIL PROTECTED]> wrote: >At 03:59 PM 7/1/2005 -0700, Ralf W. Grosse-Kunstleve wrote: > [snip] > >This extends to any number of arguments: > > class grouping: > def __init__(self, x, y, z): > self.__dict__.update(locals(

Re: [Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Phillip J. Eby
At 03:59 PM 7/1/2005 -0700, Ralf W. Grosse-Kunstleve wrote: >Hi, > >I often find myself writing: > > class grouping: > > def __init__(self, x, y, z): > self.x = x > self.y = y > self.z = z > >I hate it, and every time I show this to a Python newcomer I get that

[Python-Dev] reducing self.x=x; self.y=y; self.z=z boilerplate code

2005-07-01 Thread Ralf W. Grosse-Kunstleve
Hi, I often find myself writing: class grouping: def __init__(self, x, y, z): self.x = x self.y = y self.z = z I hate it, and every time I show this to a Python newcomer I get that skeptic look. How about this for a change? class grouping: def __i