Re: [Python-ideas] Augmented assignment syntax for objects.

2017-05-02 Thread Erik
On 26/04/17 21:50, Chris Angelico wrote: On Thu, Apr 27, 2017 at 6:24 AM, Erik wrote: The background is that what I find myself doing a lot of for private projects is importing data from databases into a structured collection of objects and then grouping and analyzing

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-05-02 Thread Brendan Barnwell
On 2017-05-01 11:50, Jerry Hill wrote: >What happens if you use this syntax in a top-level function rather >than a method? (Or a static method?) > >def function(x, y, x.attr): > ... > >(And don't forget that behind the scenes, methods*are* functions.) What >would this syntax even mean? It

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-05-01 Thread Jerry Hill
On Thu, Apr 27, 2017 at 7:21 PM, Steven D'Aprano wrote: > On Wed, Apr 26, 2017 at 03:54:22PM -0400, Jerry Hill wrote: >> On Tue, Apr 25, 2017 at 8:05 PM, Ryan Gonzalez wrote: >> > def ___init__(self, self.attr): >> >> I'm not a python developer, I'm just a

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-05-01 Thread Juancarlo Añez
On Thu, Apr 27, 2017 at 7:28 PM, Steven D'Aprano wrote: > > In my experience, what Python is lacking is a way to declare attributes > > outside of the constructor. Take a look at how it's done in C#, Swisft, > or > > Go. > > Since you apparently already know how they do it,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-29 Thread Nick Coghlan
On 29 April 2017 at 09:51, Ivan Levkivskyi wrote: > typing.NamedTuple was already mentioned in this discussion, I just would > like to add few comments: > > 1. I think that changing Python syntax to support declarative classes is not > a realistic option in nearby future. >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-29 Thread Nick Coghlan
On 29 April 2017 at 03:00, Mike Miller wrote: > On 2017-04-28 06:07, Nick Coghlan wrote: >> For a *lot* of classes, what we want to be able to define is: >> >> - a set of data fields >> - a basic initialiser to set those fields by name >> - a repr based on those fields

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-29 Thread Tin Tvrtković
On Fri, Apr 28, 2017 at 3:07 PM Nick Coghlan wrote: > Yes, the point I attempted to raise earlier: at the language design > level, "How do we make __init__ methods easier to write?" is the > *wrong question* to be asking. It's treating the symptom (writing an > imperative

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-29 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 11:04:00PM +0100, Erik wrote: > Isn't binding an object to a namespace the same operation that > assignment performs? Yes. > So it's a type of assignment, and one that doesn't require the name to > be spelled twice in the current syntax (and that's partly why I took >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-29 Thread Paul Moore
On 28 April 2017 at 23:04, Erik wrote: >> See what I mean? Things get out of hand *very* fast. > > I don't see how that's getting "out of hand". The proposal is nothing more > complicated than a slightly-different spelling of assignment. It could be > done today with a

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Erik
On 28/04/17 10:47, Paul Moore wrote: On 28 April 2017 at 00:18, Erik wrote: The semantics are very different and there's little or no connection between importing a module and setting an attribute on self. At the technical level of what goes on under the covers,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Paul Moore
On 28 April 2017 at 14:07, Nick Coghlan wrote: >> Am I missing some point? > > Yes, the point I attempted to raise earlier: at the language design > level, "How do we make __init__ methods easier to write?" is the > *wrong question* to be asking. It's treating the symptom

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Chris Angelico
On Sat, Apr 29, 2017 at 1:31 AM, Steven D'Aprano wrote: > On Fri, Apr 28, 2017 at 05:23:59PM +1000, Chris Angelico wrote: > __init__ is called, the argument 42 is bound to the formal parameter > "attr", the assignment self.attr = attr is run, and THEN the body of the > method

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Stephan Hoyer
On Fri, Apr 28, 2017 at 4:55 AM, Tin Tvrtković wrote: > I'm going to posit we need declarative classes. (This is what a library > like attrs provides, basically.) For a class to be declarative, it needs to > be possible to inspect the class for its attributes and more. > >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 05:23:59PM +1000, Chris Angelico wrote: > Waait a minute. Since when is the *declaration* doing this? That's what the suggested syntax says. You put the attribute assignment you want in the parameter list, which is part of the function/method declaration, not the

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Nick Coghlan
On 28 April 2017 at 22:26, Paul Moore wrote: > On 28 April 2017 at 12:55, Tin Tvrtković wrote: >> I'm putting forward three examples. These examples are based on attrs since >> that's what I consider to be the best way of having declarative classes in

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Nick Coghlan
On 28 April 2017 at 21:55, Tin Tvrtković wrote: > Third example: I work at a mobile games company. The backends are Python, > the games are written in other languages. The backends and the games share > data structures - requests, responses, the save game, game data. I want

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Paul Moore
On 28 April 2017 at 12:55, Tin Tvrtković wrote: > I'm putting forward three examples. These examples are based on attrs since > that's what I consider to be the best way of having declarative classes in > Python today. Your comments and examples are interesting, but don't

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Tin Tvrtković
Steven D'Aprano <st...@pearwood.info> > To: python-ideas@python.org > Subject: Re: [Python-ideas] Augmented assignment syntax for objects. > Message-ID: <20170427232853.gc22...@ando.pearwood.info> > Content-Type: text/plain; charset=iso-8859-1 > > On Wed, Apr 26, 2017 at 08

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-28 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 03:30:29PM +1000, Chris Angelico wrote: > > Obviously we can define syntax to do anything we like, but what is the > > logical connection between the syntax and the semantics? What part of > > "function parameter list" suggests "assign attributes to arbitrary > > objects"?

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Chris Angelico
On Fri, Apr 28, 2017 at 2:06 PM, Steven D'Aprano wrote: > On Fri, Apr 28, 2017 at 09:54:55AM +1000, Chris Angelico wrote: >> On Fri, Apr 28, 2017 at 9:21 AM, Steven D'Aprano wrote: >> > What happens if you use this syntax in a top-level function rather

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Steven D'Aprano
On Fri, Apr 28, 2017 at 09:54:55AM +1000, Chris Angelico wrote: > On Fri, Apr 28, 2017 at 9:21 AM, Steven D'Aprano wrote: > > What happens if you use this syntax in a top-level function rather > > than a method? (Or a static method?) > > > > def function(x, y, x.attr): > >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Steven D'Aprano
On Wed, Apr 26, 2017 at 08:02:39AM -0400, tritium-l...@sdamon.com wrote: > > self.__dict__.update(kwargs) > > Touching __dict__ feels dirty to me. Indeed. The right way is: vars(self).update(kwargs) although that doesn't work if self is written to use __slots__ instead of having a

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Steven D'Aprano
On Wed, Apr 26, 2017 at 08:52:46PM -0400, Juancarlo Añez wrote: > In my experience, what Python is lacking is a way to declare attributes > outside of the constructor. Take a look at how it's done in C#, Swisft, or > Go. Since you apparently already know how they do it, how about telling us (1)

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Steven D'Aprano
On Wed, Apr 26, 2017 at 03:54:22PM -0400, Jerry Hill wrote: > On Tue, Apr 25, 2017 at 8:05 PM, Ryan Gonzalez wrote: > > def ___init__(self, self.attr): > > I'm not a python developer, I'm just a developer that uses python. > That said, I really like this form. It eliminates

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Erik
On 27/04/17 23:43, Steven D'Aprano wrote: On Wed, Apr 26, 2017 at 11:29:19PM +0100, Erik wrote: def __init__(self, a, b, c): self import a, b self.foo = c * 100 [snarky] If we're going to randomly choose arbitrary keywords with no connection to the operation being performed, The

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Steven D'Aprano
On Wed, Apr 26, 2017 at 11:29:19PM +0100, Erik wrote: > But, if we're going to bikeshed and there is some weight behind the idea > that this "papercut" should be addressed, then given my previous > comparisons with importing, what about having 'import' as an operator: > > def __init__(self, a,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Sven R. Kunze
On 26.04.2017 23:50, Mark Lawrence via Python-ideas wrote: On 26/04/2017 21:50, Chris Angelico wrote: On Thu, Apr 27, 2017 at 6:24 AM, Erik wrote: The background is that what I find myself doing a lot of for private projects is importing data from databases into a

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Ryan Gonzalez
*cough* I'll just drop this here a sec *cough*: https://code.activestate.com/recipes/580790-auto-assign-self-attributes-in-__init__-using-pep-/ On Thu, Apr 27, 2017 at 10:24 AM, Nick Coghlan wrote: > On 25 April 2017 at 11:08, Erik wrote: >> Hi. I

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Nick Coghlan
On 25 April 2017 at 11:08, Erik wrote: > Hi. I suspect that this may have been discussed to death at some point in > the past, but I've done some searching and I didn't come up with much. Hi Erik, Offering more concise ways of writing more powerful class definitions is

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread MRAB
On 2017-04-26 23:29, Erik wrote: On 26/04/17 19:15, Mike Miller wrote: As the new syntax ideas piggyback on existing syntax, it doesn't feel like that its a complete impossibility to have this solved. Could be another "fixed papercut" to drive Py3 adoption. Taken individually not a big deal

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Juancarlo Añez
On Wed, Apr 26, 2017 at 6:57 PM, Mike Miller wrote: > Yes, I like it too. Removes the triple repetition, and has precedent in > the other languages. This discussion has been around how to deal with repetition in object constructors, and the proposals have been a new

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Mike Miller
Yes, I like it too. Removes the triple repetition, and has precedent in the other languages. On 2017-04-26 12:54, Jerry Hill wrote: On Tue, Apr 25, 2017 at 8:05 PM, Ryan Gonzalez wrote: def ___init__(self, self.attr): I'm not a python developer, I'm just a developer

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 23:28, Paul Moore wrote: Or to put it another way, if the only reason for the syntax proposal is performance then show me a case where performance is so critical that it warrants a language change. It's the other way around. The proposal (arguably) makes the code clearer but does

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 19:15, Mike Miller wrote: As the new syntax ideas piggyback on existing syntax, it doesn't feel like that its a complete impossibility to have this solved. Could be another "fixed papercut" to drive Py3 adoption. Taken individually not a big deal but they add up. *sigh* OK, this

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Paul Moore
On 26 April 2017 at 22:42, Erik wrote: > 2) The original proposal, which does belong on -ideas and has to take into > account the general case, not just my specific use-case. > > The post you are responding to is part of (2), and hence reduced performance > is a

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Mark Lawrence via Python-ideas
On 26/04/2017 21:50, Chris Angelico wrote: On Thu, Apr 27, 2017 at 6:24 AM, Erik wrote: The background is that what I find myself doing a lot of for private projects is importing data from databases into a structured collection of objects and then grouping and

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 22:28, Paul Moore wrote: On 26 April 2017 at 21:51, Erik wrote: It doesn't make anything more efficient, however all of the suggestions of how to do it with current syntax (mostly decorators) _do_ make things less efficient. Is instance creation the

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Paul Moore
On 26 April 2017 at 21:51, Erik wrote: > It doesn't make anything more efficient, however all of the suggestions of > how to do it with current syntax (mostly decorators) _do_ make things less > efficient. Is instance creation the performance bottleneck in your

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 01:39, Nathaniel Smith wrote: [snip discussion of why current augmented assignment operators are better for other reasons] Are there any similar arguments for .=? It doesn't make anything more efficient, however all of the suggestions of how to do it with current syntax (mostly

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Chris Angelico
On Thu, Apr 27, 2017 at 6:24 AM, Erik wrote: > The background is that what I find myself doing a lot of for private > projects is importing data from databases into a structured collection of > objects and then grouping and analyzing the data in different ways before >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 16:10, Nick Timkovich wrote: I was wondering that if there are so many arguments to a function that it *looks* ugly, that it might just *be* ugly. For one, too many required arguments to a function (constructor, whatever) is already strange. Binding them as attributes of the object,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Jerry Hill
On Tue, Apr 25, 2017 at 8:05 PM, Ryan Gonzalez wrote: > def ___init__(self, self.attr): I'm not a python developer, I'm just a developer that uses python. That said, I really like this form. It eliminates most of the redundancy, while still being explicit. It's true that you

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 18:42, Mike Miller wrote: I want to be able to say: def __init__(self, foo, bar, baz, spam): self .= foo, bar, spam self.baz = baz * 100 I don't see ALL being set a big problem, and less work than typing several of them out again. Because, some of the parameters might be

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Mike Miller
On 2017-04-25 15:05, Paul Moore wrote: It seems to me that the number of people for whom both of the following hold: 1. Writing out the assignments "longhand" is an unacceptable burden. 2. Using a decorator (which can be written directly in your project, doesn't even need to be an external

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread MRAB
On 2017-04-26 18:46, Mike Miller wrote: On 2017-04-26 04:12, Brice PARENT wrote: Why not simply do this : class MyClass: def _set_multiple(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) def __init__(self, a, b, c):

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Juancarlo Añez
On Wed, Apr 26, 2017 at 11:17 AM, Erik wrote: > I had forgotten that decorators could take parameters. Something like that > pretty much ticks the boxes for me. > There are decorators with "include" and "included" in this SO Q:

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Mike Miller
On 2017-04-26 04:12, Brice PARENT wrote: Why not simply do this : class MyClass: def _set_multiple(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) def __init__(self, a, b, c): self._set_multiple(a=a, b=b, c=c) If the goal is

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Mike Miller
On 2017-04-25 15:30, Erik wrote: All of the decorators (or other language tricks that modify the object's dict) suggested so far assume that ALL of the method's arguments are to be assigned. I do not want that. I want to be able to say: def __init__(self, foo, bar, baz, spam): self .= foo,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Paul Moore
On 26 April 2017 at 16:17, Erik wrote: > On 26/04/17 08:59, Paul Moore wrote: >> >> It should be possible to modify the decorator to take a list >> of the variable names you want to assign, but I suspect you won't like >> that > > > Now you're second-guessing me. Sorry

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 08:59, Paul Moore wrote: It should be possible to modify the decorator to take a list of the variable names you want to assign, but I suspect you won't like that Now you're second-guessing me. > class MyClass: > @auto_args('a', 'b') > def __init__(self, a, b, c=None): >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Erik
On 26/04/17 13:19, Joao S. O. Bueno wrote: On 25 April 2017 at 19:30, Erik wrote: decorators don't cut it anyway (at least not those proposed) because they blindly assign ALL of the arguments. I'm more than happy to hear of something that solves both of those problems

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Carlo Miron
On Wed, Apr 26, 2017 at 2:02 PM, wrote: >> On Wed, Apr 26, 2017 at 01:12:14PM +0200, Brice PARENT >> wrote: >> > def _set_multiple(self, **kwargs): >> > for key, value in kwargs.items(): >> > setattr(self, key, value) >> >>

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Joao S. O. Bueno
On 25 April 2017 at 19:30, Erik wrote: > And as I also said above, decorators don't cut it anyway (at least not those > proposed) because they blindly assign ALL of the arguments. I'm more than > happy to hear of something that solves both of those problems without >

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Oleg Broytman
On Wed, Apr 26, 2017 at 01:12:14PM +0200, Brice PARENT wrote: > def _set_multiple(self, **kwargs): > for key, value in kwargs.items(): > setattr(self, key, value) self.__dict__.update(kwargs) Oleg. -- Oleg Broytman

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-26 Thread Paul Moore
On 25 April 2017 at 23:30, Erik wrote: > As I said above, it's not about the effort writing it out. It's about the > effort (and accuracy) of reading the code after it has been written. Well, personally I find all of the syntax proposals relatively unreadable. So that's

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Juancarlo Añez
On Tue, Apr 25, 2017 at 6:09 PM, Paul Moore wrote: > (Arguing for auto_args to be in the stdlib may be a better option than > arguing for new syntax, BTW...) > Having such a decorator in the stdlib would allow IDEs and syntax highlighters to know what's going on. --

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Nathaniel Smith
On Tue, Apr 25, 2017 at 3:30 PM, Erik wrote: > On 25/04/17 23:05, Paul Moore wrote: >> >> 1. Writing out the assignments "longhand" is an unacceptable burden. > > > There are reasons why augmented assignment was implemented. One of them was > to make the code easier to

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Chris Angelico
On Wed, Apr 26, 2017 at 10:05 AM, Ryan Gonzalez wrote: > FWIW I always liked > Dart's/Ruby's/Crystal's/(Coffee|Moon)Script's/WhateverElse's style: > > > class Cls { > Cls(this.a); // IT'S MAGIC > } > > > but the Python equivalent is admittedly weirder: > > > def

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Ryan Gonzalez
FWIW I always liked Dart's/Ruby's/Crystal's/(Coffee|Moon)Script's/WhateverElse's style: class Cls { Cls(this.a); // IT'S MAGIC } but the Python equivalent is admittedly weirder: def ___init__(self, self.attr): partly because, it'd have to work on pretty much any other variable name, yet

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Matt Gilson
On Tue, Apr 25, 2017 at 4:31 PM, Erik wrote: > On 25/04/17 22:15, Brice PARENT wrote: > >> it may be easier to get something like this >> (I think, as there is no new operator involved) : >> > > No new operator, but still a syntax change, so that doesn't help from that

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Erik
On 25/04/17 22:15, Brice PARENT wrote: it may be easier to get something like this (I think, as there is no new operator involved) : No new operator, but still a syntax change, so that doesn't help from that POV. def __init__(self, *args, **kwargs): self.* = *args self.** =

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Erik
On 25/04/17 02:15, Chris Angelico wrote: Bikeshedding: Your example looks a lot more like tuple assignment than multiple assignment. Well, originally, I thought it was just the spelling-the-same-name-twice thing that irritated me and I was just going to suggest a single assignment version

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Mike Miller
On 2017-04-25 14:15, Brice PARENT wrote: But, any of these proposals, mine and yours, if you really need this to shorten the code writing time or vertical space only, is not a better idea than to propose a macro to your IDE editor, or a pull request if it's open source. Such a macro would

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Mike Miller
Agreed with Steven, although I do find myself a little more annoyed and bothered by a typical init than him I guess. Even so I didn't think the current proposals went far enough. To tilt the balance farther, to make it easier, let's go all the way! Instead of continuing duplication: >>>

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Tin Tvrtković
n-Ideas <python-ideas@python.org>, "Steven D'Aprano" > <st...@pearwood.info> > Subject: Re: [Python-ideas] Augmented assignment syntax for objects. > Message-ID: > < > cafwcp0gjg1bxeq2pmv637bxg6+vcxivu1qnekdetuhjmot_...@mail.gmail.com> > Content

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread George Fischhof
2017. ápr. 25. de. 10:04 ezt írta ("Paul Moore" ): On 25 April 2017 at 03:53, Steven D'Aprano wrote: > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > >> I often find myself writing __init__ methods of the form: >> >> def __init__(self, foo, bar,

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Daniel Moisset
I actually saw a decorator like that last week, https://twitter.com/judy2k/status/854330478068977664 On 25 April 2017 at 08:56, Paul Moore wrote: > On 25 April 2017 at 03:53, Steven D'Aprano wrote: > > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Paul Moore
On 25 April 2017 at 03:53, Steven D'Aprano wrote: > On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > >> I often find myself writing __init__ methods of the form: >> >> def __init__(self, foo, bar, baz, spam, ham): >> self.foo = foo >> self.bar = bar >> self.baz =

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-24 Thread Nathaniel Smith
On Mon, Apr 24, 2017 at 6:08 PM, Erik wrote: > Hi. I suspect that this may have been discussed to death at some point in > the past, but I've done some searching and I didn't come up with much. > Apologies if I'm rehashing an old argument ;) > > I often find myself

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-24 Thread Steven D'Aprano
On Tue, Apr 25, 2017 at 02:08:05AM +0100, Erik wrote: > I often find myself writing __init__ methods of the form: > > def __init__(self, foo, bar, baz, spam, ham): > self.foo = foo > self.bar = bar > self.baz = baz > self.spam = spam > self.ham = ham > > This seems a little wordy and

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-24 Thread Chris Angelico
On Tue, Apr 25, 2017 at 11:08 AM, Erik wrote: > The suggestion therefore is: > > def __init__(self, foo, bar, baz, spam, ham): > self .= foo, bar, baz, spam, ham > > This is purely syntactic sugar for the original example: > > def __init__(self, foo, bar, baz, spam,

[Python-ideas] Augmented assignment syntax for objects.

2017-04-24 Thread Erik
Hi. I suspect that this may have been discussed to death at some point in the past, but I've done some searching and I didn't come up with much. Apologies if I'm rehashing an old argument ;) I often find myself writing __init__ methods of the form: def __init__(self, foo, bar, baz, spam,