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.
In contrast, there is an existing syntax change - variable annotations -
that can be
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, yes. At the higher
level of wh
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 (writing an
> imperative
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 is called. (Before yo
On 2017-04-28 06:07, Nick Coghlan wrote:
…the root cause (writing imperative initialisers is still
part of the baseline recommendation for writing classes, and we don't
offer any supporting infrastructure for avoiding that directly in the
standard library)
For a *lot* of classes, what we want t
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.
>
> I'm putting forward th
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 bo
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
>> Python today.
>
> Your comments and exampl
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 to
> have a single sour
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 they just come
down to "
I'm gonna take a shot at elaborating this point.
We Python programmers often tout Python as a high-level, high-productivity
language where complex and useful things are easy to do. However, vanilla
Python classes are anything but high level; they're basically glorified
dictionaries that require an
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, yes. At the higher
> level of what the words mean in spoken En
On Fri, Apr 28, 2017 at 5:02 PM, Random832 wrote:
> On Fri, Apr 28, 2017, at 01:30, Chris Angelico wrote:
>> Nothing whatsoever says that this is a good idea, but it's perfectly
>> legal, because the for loop is defined in terms of assignment. If this
>> were to be accepted (which, fwiw, I'm not a
On Fri, Apr 28, 2017 at 4:57 PM, Steven D'Aprano wrote:
> 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 paramete
On Fri, Apr 28, 2017, at 01:30, Chris Angelico wrote:
> Nothing whatsoever says that this is a good idea, but it's perfectly
> legal, because the for loop is defined in terms of assignment. If this
> were to be accepted (which, fwiw, I'm not actually advocating, but
> IF), it would also be defined
15 matches
Mail list logo