[Python-ideas] Re: Towards better type annotations enabled by PEP-0563, was: Re: Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Tiago Illipronti Girardi
IMHO, if `->` becomes an operator with semantics, then `[t1, ..., tn] -> tr` should mean `typing.Callable[[t1, ..., tn], tr]`. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://m

[Python-ideas] Re: Towards better type annotations enabled by PEP-0563, was: Re: Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Greg Ewing
On 24/05/20 10:26 am, Paul Sokolovsky wrote: On Mon, 18 May 2020 13:25:50 +1200 Greg Ewing wrote: Or maybe we could leverage the new walrus operator and write str := (int) With the idea that someone may confuse ":=" for "<-", so we can swap result and argument types comparing to their

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Tiago Illipronti Girardi
Wouldn't it be better implemented on an editor as a display option instead of changing python? Because, as I understand, it's an issue of appearing nice on screen, rather than storing (and parsing) `'\u2192'` as an alias to `'->'` on type hints. It *would* look nice, though _

[Python-ideas] Re: Python GIL Thoughts

2020-05-23 Thread Edwin Zimmerman
On 5/23/2020 6:24 PM, redrad...@gmail.com wrote: > Hi all, > > I am very exciting about the sub-interpreters ... but I do not like some > parts ... > Consider the following code: > ```python > import _xxsubinterpreters as interpreters > import threading > import textwrap as tw > import marshal > >

[Python-ideas] Python GIL Thoughts

2020-05-23 Thread redradist
Hi all, I am very exciting about the sub-interpreters ... but I do not like some parts ... Consider the following code: ```python import _xxsubinterpreters as interpreters import threading import textwrap as tw import marshal if __name__ == '__main__': # Create a sub-interpreter interpid

[Python-ideas] Towards better type annotations enabled by PEP-0563, was: Re: Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Paul Sokolovsky
Hello, On Mon, 18 May 2020 02:39:27 +0100 MRAB wrote: [] > > Or maybe we could leverage the new walrus operator and write > > > > str := (int) > > > It would be closer to the existing annotation if we could write: > > [int] -> str To make it clear, the talk is about "better", n

[Python-ideas] Towards better type annotations enabled by PEP-0563, was: Re: Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Paul Sokolovsky
Hello, On Mon, 18 May 2020 13:25:50 +1200 Greg Ewing wrote: > On 18/05/20 1:59 am, Paul Sokolovsky wrote: > > But even > > {(int): str} is a better type annotation for a function than > > Callable[[int], str]. > > I don't agree -- it looks more like some kind of dict type, and > would be bett

[Python-ideas] Re: Python tagged unions based on dataclasses

2020-05-23 Thread Paul Sokolovsky
Hello, On Sat, 23 May 2020 21:52:47 +0900 "Stephen J. Turnbull" wrote: > Paul Sokolovsky writes: > > Andrey Cizov wrote: > > > > Sorry I forgot to add the URL: > > > https://pypi.org/project/tagged-dataclasses/ > > > As a quick comment, looks verbose comparing to ML ;-). > > Do you

[Python-ideas] Re: Optional keyword arguments

2020-05-23 Thread Tiago Illipronti Girardi
A programmer making the least effort wouldn't update themselves on the grammar: the patch would be useless. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mai

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Stephen J. Turnbull
Christopher Barker writes: > Interesting -- in other recent threads, Ive felt that those of us that > thought "iterators and `next" were relatively advanced concepts that > newbies didn't need to learn were dismissed ... I for one don't *dismiss* that idea iterators and next are advanced, but

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-23 Thread Christopher Barker
On Fri, May 22, 2020 at 4:23 AM Steven D'Aprano wrote: > In pseudo-code: > > - create a temporary file of 2048 bytes; > - write a NTFS file system in that file; > - mount that file system somewhere so it is visible; > > So have the test create a new file system on the fly, cd into that file > sys

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Christopher Barker
> > for obj in somelist: > > > if comparison(obj, needle): > > > do_something(obj) > > > break > People who think in functional programming terms will probably love the > `next(filter(...))` idiom, but not everyone thinks or likes functional > programming idioms

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Dan Sommers
On Saturday, May 23, 2020, at 11:02 -0400, David Mertz wrote: > Still, generator comprehension are great. And next() is an excellent > function. Agreed, on both counts. I often end up needing an arbitrary element of a set (or the only element of a single-element set), and next(iter(set)) scrat

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread David Mertz
On Sat, May 23, 2020, 10:54 AM Rob Cliffe via Python-ideas > index_of(needle, haystack, key=func) > > Sounds like a list comprehension: [ needle for needle in haystack if > func(needle) ] > The times it doesn't sound like a list comprehension is when you have a million items in the list, 100k of

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Rob Cliffe via Python-ideas
On 23/05/2020 05:48, David Mertz wrote: On Sat, May 23, 2020, 12:26 AM Steven D'Aprano Obviously not all such key functions are that simple and you may need to write a helper function, but the same applies to filter. I like the key function much better than the predicate. In large pa

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Edwin Zimmerman
On 5/23/2020 8:52 AM, Stephen J. Turnbull wrote: > Executive summary: > > I'd like to make three points. > > 1. Accessibility matters, and I think this change would be > inaccessible to users of screen readers. > 2. Yes, a variety of tools imposes a burden, but also confers > benefits. >

[Python-ideas] Re: Optional keyword arguments

2020-05-23 Thread Alex Hall
On Sat, May 23, 2020 at 2:52 PM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Alex Hall writes: > > > In all cases it's not immediately clear what the actual default value > is, > > or even what kind of object is meant to be passed to that parameter. > > I agree with the ba

[Python-ideas] Re: Optional keyword arguments

2020-05-23 Thread Stephen J. Turnbull
Alex Hall writes: > In all cases it's not immediately clear what the actual default value is, > or even what kind of object is meant to be passed to that parameter. I agree with the basic principle, but I'm not sure this is a very strong argument. First, if you want to indicate what the type o

[Python-ideas] Re: Python tagged unions based on dataclasses

2020-05-23 Thread Stephen J. Turnbull
Paul Sokolovsky writes: > Andrey Cizov wrote: > > Sorry I forgot to add the URL: > > https://pypi.org/project/tagged-dataclasses/ > As a quick comment, looks verbose comparing to ML ;-). Do you mean ML, the language? ___ Python-ideas mailing list

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Stephen J. Turnbull
Executive summary: I'd like to make three points. 1. Accessibility matters, and I think this change would be inaccessible to users of screen readers. 2. Yes, a variety of tools imposes a burden, but also confers benefits. 3. There's no such thing as "pretty source code." There are onl

[Python-ideas] Re: Python tagged unions based on dataclasses

2020-05-23 Thread Andrey Cizov
Most of the prior art to this tries to take too much from other languages (e.g. using match as you show here). For example they create their own DSL for matching that either introduces the magic function for matching, which doesn’t completely support Python classes (e.g what if I want my tagged un

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-23 Thread Rhodri James
On 22/05/2020 20:40, Steven D'Aprano wrote: Imagine the confusion if somebody had variables spam, Spam, sPAM, SPam, sPAm. Or worse, SPΑM, SPАM and SPAM. Randall is way ahead of you. https://xkcd.com/2309/ :-) -- Rhodri James *-* Kynesim Ltd ___ Pyt