[Python-ideas] typing.modifiers

2016-09-15 Thread אלעזר
With the new variable annotation syntax, it is possible to implement a useful "modifiers" library, all used as superclasses. Possible modifiers: * Named / Struct: annotation-defined fields. No monkey patching. * Immutable / Const * Sealed / Final: unsubclassable class * Array: a mutable tu

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Chris Angelico
On Fri, Sep 16, 2016 at 4:26 AM, Guido van Rossum wrote: > Please update the docs. Roger that. http://bugs.python.org/issue28172 ChrisA ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Steven D'Aprano
On Fri, Sep 16, 2016 at 03:54:18AM +1000, Chris Angelico wrote: > On Fri, Sep 16, 2016 at 3:03 AM, Steven D'Aprano wrote: > > On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: > > > >> Perhaps the advice needs to be along the lines of: Decide what the > >> purpose of the enum is, and

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Guido van Rossum
Please update the docs. On Thu, Sep 15, 2016 at 11:14 AM, Chris Angelico wrote: > On Fri, Sep 16, 2016 at 4:06 AM, Guido van Rossum wrote: >>> Sometimes they function as integer constants (esp IntEnum), and >>> sometimes more as just arbitrary values. See the examples in the docs >>> [1] for Col

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Chris Angelico
On Fri, Sep 16, 2016 at 4:06 AM, Guido van Rossum wrote: >> Sometimes they function as integer constants (esp IntEnum), and >> sometimes more as just arbitrary values. See the examples in the docs >> [1] for Color and Mood, where the exact value is immaterial, just as >> long as Color.red is not C

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Guido van Rossum
On Thu, Sep 15, 2016 at 10:54 AM, Chris Angelico wrote: > On Fri, Sep 16, 2016 at 3:03 AM, Steven D'Aprano wrote: >> On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: >> >>> Perhaps the advice needs to be along the lines of: Decide what the >>> purpose of the enum is, and follow a n

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Chris Angelico
On Fri, Sep 16, 2016 at 3:03 AM, Steven D'Aprano wrote: > On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: > >> Perhaps the advice needs to be along the lines of: Decide what the >> purpose of the enum is, and follow a naming convention accordingly. >> Uppercase if you're basically

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Ethan Furman
On 09/15/2016 10:03 AM, Steven D'Aprano wrote: On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: Perhaps the advice needs to be along the lines of: Decide what the purpose of the enum is, and follow a naming convention accordingly. Uppercase if you're basically making constants;

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Steven D'Aprano
On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: > Perhaps the advice needs to be along the lines of: Decide what the > purpose of the enum is, and follow a naming convention accordingly. > Uppercase if you're basically making constants; lowercase if you're > not; etcetera. I can't

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread Nick Coghlan
On 15 September 2016 at 21:11, אלעזר wrote: > Yes the "class A[T]:" syntax requires on the ability to express variance as > an operator, but not the other way around. > > It might be an argument in favor of switching to the + syntax: to make > possible future syntax change in class definition some

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread אלעזר
Yes the "class A[T]:" syntax requires on the ability to express variance as an operator, but not the other way around. It might be an argument in favor of switching to the + syntax: to make possible future syntax change in class definition somewhat easier to swallow. ~Elazar On Thu, Sep 15, 2016

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread Nick Coghlan
On 15 September 2016 at 19:53, Ivan Levkivskyi wrote: > > > On 15 September 2016 at 11:46, אלעזר wrote: >> >> And that thread is only about variance. What about the generic syntax? > > > If you mean code like this: > > class Container[+T]: > @abstractmethod > def __contains__

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread Ivan Levkivskyi
On 15 September 2016 at 11:46, אלעזר wrote: > And that thread is only about variance. What about the generic syntax? > If you mean code like this: class Container[+T]: @abstractmethod def __contains__(self, x: T) -> bool: ... then there is little chance that this will be a

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread אלעזר
And that thread is only about variance. What about the generic syntax? ‪On Thu, Sep 15, 2016 at 12:44 PM ‫אלעזר‬‎ wrote:‬ > Does that mean that if I did, it would be reconsidered? > > On Thu, Sep 15, 2016 at 12:43 PM Ivan Levkivskyi > wrote: > >> On 15 September 2016 at 11:21, אלעזר wrote: >>

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread אלעזר
Does that mean that if I did, it would be reconsidered? On Thu, Sep 15, 2016 at 12:43 PM Ivan Levkivskyi wrote: > On 15 September 2016 at 11:21, אלעזר wrote: > >> This suggestion is so obvious that it's likely has been discussed, but I >> can't find any reference (It's not what PEP-3124 talks a

Re: [Python-ideas] Generics Syntax

2016-09-15 Thread Ivan Levkivskyi
On 15 September 2016 at 11:21, אלעזר wrote: > This suggestion is so obvious that it's likely has been discussed, but I > can't find any reference (It's not what PEP-3124 talks about). > > You might want to read this tread https://github.com/python/typing/issues/211 and another tread mentioned the

[Python-ideas] Generics Syntax

2016-09-15 Thread אלעזר
This suggestion is so obvious that it's likely has been discussed, but I can't find any reference (It's not what PEP-3124 talks about). Generic class syntax, now: _T_co = TypeVar('_T', covariant=True) class Container(Generic[_T_co]): @abstractmethod def __contains__(self,