[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-01-29 Thread Christopher Barker
On Thu, Jan 28, 2021 at 4:25 PM Inada Naoki wrote: > > The "real" solution is to change the defaults not to use the system > encoding at all -- which, of course, we are moving towards with PEP 597. So > first a plug to do that as fast as possible! I myself would love to see PEP > 597 implemented

[Python-ideas] Re: Questions about using PEP 637 syntax in PEP 646

2021-01-29 Thread Brandt Bucher
Guido van Rossum wrote: > Honestly I think it's fine the way you have implemented it -- since there is > a difference between a[1] and a[1,], a[*t] where len(t) == 1 has to make a > choice, and it's fine if this always passes a tuple. Yup, I agree. Not only because it feels more intuitive to me

[Python-ideas] Re: Questions about using PEP 637 syntax in PEP 646

2021-01-29 Thread Guido van Rossum
On Fri, Jan 29, 2021 at 2:28 AM Stefano Borini wrote: > On Tue, 19 Jan 2021 at 13:51, wrote: > > > > Hello, > > > > This is a great PEP. It turns out to be applicable in a variety of > scenarios. > > > > Case in point: Matthew Rahtz and I are working on PEP 646: Variadic > Generics (https://www.

[Python-ideas] Re: List .index() Method

2021-01-29 Thread Greg Ewing
On 30/01/21 3:27 am, Francis O'Hara Aidoo wrote: listy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] if listy.index(10) == -1:   print("Monty Python") > Although ambiguity will make it difficult to implement, The difficulty isn't just with implementation, it's with *specification*. How is it

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread Paul Bryan
A little less verbose: import typing.Annotated as A def request( method: A[str, "The method to perform"], url: A[str, "The URL to submit request to"], ... ) -> Response: """Constructs and sends a request.""" ... On Fri, 2021-01-29 at 13:43 -0800, abed...@gmail.com wrote: > *

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread abed...@gmail.com
*I was hoping for something a little less *verbose* I left out the word "verbose". I'll tripple check my next post. Sorry again. On Friday, January 29, 2021 at 3:41:17 PM UTC-6 abed...@gmail.com wrote: > That could work. I'm not super familiar with typing.Annotated. I was > hoping for something

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread abed...@gmail.com
That could work. I'm not super familiar with typing.Annotated. I was hoping for something a little less though my example doesn't really show that with the way used commas. Thinking about it more, it should be possible for the parser to recognize a comma followed by a comment within a function s

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread Paul Bryan
Or now, thinking more about it, why not simplify it by having a string literal in Annotated just represent its docstring?  def request( method: Annotated[str, "The method to perform"], url: Annotated[str, "The URL to submit request to"], ... ) -> Response: """Constructs and sends a

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread Paul Bryan
Perhaps this would be a good opportunity to start looking at typing.Annotated[...] as a mechanism for parameter documentation? Something like: def request( method: Annotated[str, Doc("The method to perform")], url: Annotated[str, Doc("The URL to submit request to")], ... ) -> Response:

[Python-ideas] Re: Parameter documentation

2021-01-29 Thread abed...@gmail.com
Sorry, I accidentally hit "post message" too soon. The idea is that python would somehow construct a more complete doc-string from the function doc-string and it's signature/parameter doc-strings. On Friday, January 29, 2021 at 2:29:51 PM UTC-6 abed...@gmail.com wrote: > Currently, python allow

[Python-ideas] Parameter documentation

2021-01-29 Thread abed...@gmail.com
Currently, python allows variable documentation via PEP 526 . For most functions with short parameter lists that can fit in a reasonable column limit, I prefer the traditional declaration style with Google-style doc strings: *def connect_to_next_port(s

[Python-ideas] Re: List .index() Method

2021-01-29 Thread William Pickard
index is meant to return the index of the first match it finds in the list from the beginning, it's most simpless implementation is: ``` for i, v in enumerate(self): if v == value: return i throw ValueError(f"Value '{value}' is not in list") if you want the negative index, just

[Python-ideas] List .index() Method

2021-01-29 Thread Francis O'Hara Aidoo
Hello, I'm Francis, a beginner programmer from Ghana, West Africa. I was wondering why the list .index() method doesn't return negative indices as well as well as positive indices. Although ambiguity will make it difficult to implement, in certain cases, it would be useful if it could return the ne

[Python-ideas] Re: Questions about using PEP 637 syntax in PEP 646

2021-01-29 Thread Stefano Borini
On Tue, 19 Jan 2021 at 13:51, wrote: > > Hello, > > This is a great PEP. It turns out to be applicable in a variety of scenarios. > > Case in point: Matthew Rahtz and I are working on PEP 646: Variadic Generics > (https://www.python.org/dev/peps/pep-0646/; discussion on typing-sig). It is > a ty