__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-31 Thread falcon
Hello python-list, As I Understood, semantic may be next: def qwerty(a,a.i,b,b.i,f.j): pass Would work like: def qwerty(anonymous1,anonymous2,anonymous3,anonymous4,anonymous5): (a,a.i,b,b.i,f.j)=(anonymous1,anonymous2,anonymous3,anonymous4,anonymous5) del anonymous1

Re: __autoinit__

2005-07-12 Thread Ralf W. Grosse-Kunstleve
--- Mike Meyer [EMAIL PROTECTED] wrote: Remember that what we're suggesting is just syntactic sugar. BTW: That's true for all high-level language constructs. You could do everything in machine language. A good language is the sum of lots of syntactic sugar... selected with taste. :) You can

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Reinhold Birkenfeld
Kay Schluehr wrote: Dan Sommers schrieb: How about this: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Can you tell me in which way it is anyhow better than the original proposal def

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Kay Schluehr
Reinhold Birkenfeld schrieb: Kay Schluehr wrote: Dan Sommers schrieb: How about this: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Can you tell me in which way it is anyhow better than

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Dan Sommers
On Mon, 11 Jul 2005 08:34:45 +0200, Reinhold Birkenfeld [EMAIL PROTECTED] wrote: Kay Schluehr wrote: Dan Sommers schrieb: How about this: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Can you tell me in which

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Reinhold Birkenfeld
Dan Sommers wrote: Without thinking it all the way through, I suppose these: def method_1(self, *self.l): pass def method_2(self, **self.d): pass could act as if they were these: def method_1(self, *args): self.l = args del args def

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Bengt Richter
On Mon, 11 Jul 2005 01:44:07 -0400, Terry Reedy [EMAIL PROTECTED] wrote: Bengt Richter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Me too. I liked the leading _, but on second thought it is a weird language change re names in a special context. Probably not so good. To

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Bengt Richter
On Mon, 11 Jul 2005 15:37:35 +0200, Reinhold Birkenfeld [EMAIL PROTECTED] wrote: Dan Sommers wrote: Without thinking it all the way through, I suppose these: def method_1(self, *self.l): pass def method_2(self, **self.d): pass could act as if they were these:

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Ralf W. Grosse-Kunstleve
support. I think it would be fantastic if we could push through the def __init__(self, self.x, y, self.y) syntax, with the explicit limitation that only the first argument can be used on the left side of the dot. I'd also happily settle for a decorator approach, __autoinit__ or over variations

Re: __autoinit__

2005-07-11 Thread Mike Meyer
Ralf W. Grosse-Kunstleve [EMAIL PROTECTED] writes: --- Bengt Richter [EMAIL PROTECTED] wrote: No, that limitation wouldn't exist, so you wouldn't have to explain it ;-) I.e., the above would act like class Foo: x = Bar() def method_1(self, _anonymous_arg_1): x.y =

Re: __autoinit__

2005-07-11 Thread Dan Sommers
On Mon, 11 Jul 2005 19:37:03 -0400, Mike Meyer [EMAIL PROTECTED] wrote: The question is - how far are you really willing to carry this? What do you think of allowing arbitrary lvalues, with the assumption that the previous arguments are all defined (ala let*)? So you could do: class

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Ralf W. Grosse-Kunstleve
be irreversible in practical applications. My __autoinit__ suggestion would result in (assuming object supports this by default): class grouping(object): def __autoinit__(self, x, y, z): pass I think that's far more intuitive. Being intuitive is relative to someones

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Terry Reedy
Ralf W. Grosse-Kunstleve [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a suggestion I don't remember seeing for flagging which vars to autoinit without new syntax: use '_' instead of '.'. I have never seen local vars with a leading '_'. So, in combination with whatever

AST decoration vs byte-code-munging (Was: Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code))

2005-07-10 Thread Bengt Richter
On Sun, 10 Jul 2005 16:26:24 -0400, Terry Reedy [EMAIL PROTECTED] wrote: Ralf W. Grosse-Kunstleve [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a suggestion I don't remember seeing for flagging which vars to autoinit without new syntax: use '_' instead of '.'. I have never

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Dan Sommers
On Sun, 10 Jul 2005 16:26:24 -0400, Terry Reedy [EMAIL PROTECTED] wrote: Ralf W. Grosse-Kunstleve [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a suggestion I don't remember seeing for flagging which vars to autoinit without new syntax: use '_' instead of '.'. I have

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Paul Rubin
Dan Sommers [EMAIL PROTECTED] writes: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Hey, I like that. -- http://mail.python.org/mailman/listinfo/python-list

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Terry Reedy
Dan Sommers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Sun, 10 Jul 2005 16:26:24 -0400, Terry Reedy [EMAIL PROTECTED] wrote: I have a suggestion I don't remember seeing for flagging which vars to autoinit without new syntax: use '_' instead of '.'. I have never seen local

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Dan Sommers
On Sun, 10 Jul 2005 20:11:38 -0400, Terry Reedy [EMAIL PROTECTED] wrote: Dan Sommers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] That's a pretty big change; now all formal parameters beginning with an underscore have a brand new meaning. As I said, 'in combination with

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Bengt Richter
On 10 Jul 2005 16:07:40 -0700, Paul Rubin http://[EMAIL PROTECTED] wrote: Dan Sommers [EMAIL PROTECTED] writes: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Hey, I like that. Me too. I liked the

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Kay Schluehr
Dan Sommers schrieb: How about this: def __init__(self, self.x, y, self.z): # self.x, self.z from first and third explicit parameters do_something_with_y() Can you tell me in which way it is anyhow better than the original proposal def __init__(self, .x, y, .z):

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Terry Reedy
Bengt Richter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Me too. I liked the leading _, but on second thought it is a weird language change re names in a special context. Probably not so good. To repeat: while my '_' proposal could have been for a language change (in 3.0),

__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Ralf W. Grosse-Kunstleve
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object): def __init__(self, *args, **keyword_args): self.__dict__.update( zip(self.__autoinit__

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Kay Schluehr
Ralf W. Grosse-Kunstleve schrieb: My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... Well ... yes ;) Ralf, if you want to modify the class instantiation behaviour you should have a look on metaclasses. That's what they

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Ralf W. Grosse-Kunstleve
--- Kay Schluehr [EMAIL PROTECTED] wrote: Ralf, if you want to modify the class instantiation behaviour you I don't. I simply want to give the user a choice: __init__(self, ...) # same as always (no modification) or __autoinit__(self, ...) # self.x=x job done automatically

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Ralf W. Grosse-Kunstleve
plain_adopt_grouping: def __init__(self, x, y, z): plain_adopt() class autoinit(object): def __init__(self, *args, **keyword_args): self.__dict__.update( zip(self.__autoinit__.im_func.func_code.co_varnames[1:], args)) self.__dict__.update(keyword_args) self.__autoinit__

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Scott David Daniels
.update( zip(self.__autoinit__.im_func.func_code.co_varnames[1:], args)) self.__dict__.update(keyword_args) self.__autoinit__(*args, **keyword_args) Should be: class autoinit(object): def __init__(self, *args, **keyword_args): for name, value in zip(self

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Ralf W. Grosse-Kunstleve
--- Scott David Daniels [EMAIL PROTECTED] wrote: Should be: class autoinit(object): def __init__(self, *args, **keyword_args): for name, value in zip(self.__autoinit__.im_func.func_code. co_varnames[1:], args

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-09 Thread Kay Schluehr
fine-tuning capabilities. The auto_ prefix is all the declarative magic. My __autoinit__ suggestion would result in (assuming object supports this by default): class grouping(object): def __autoinit__(self, x, y, z): pass I think that's far more intuitive. Being intuitive