[Python-ideas] Re: Confusing naming of Optional type should be changed

2022-07-12 Thread Kevin Mills
While confusion with optional arguments is somewhat unfortunate, the name came from an already established convention. A lot of languages have exactly the same concept, varying between names like Optional, Option, and Maybe. I don't think coming up with a Python-specific name for the same thing

[Python-ideas] Slice 'size' parameter (in the style of pairwise)

2022-06-03 Thread Kevin
I might be posting this prematurely, but I had an idea and wanted to float it. Also, I'm new here so hopefully this is appropriate. How about augmenting slicing with an additional parameter 'size' (name chosen to achieve alliteration; 'start', 'stop', 'step', and 'size'), as such: >>> a_list =

[Python-ideas] Re: Add function for reading a specific number of bytes/characters from a file object that fails noisily

2022-03-03 Thread Kevin Mills
I actually initially was going to suggest a `strict` flag get added, but I figured that would be impractical. I was mostly concerned about classes that mimic file objects, because (obviously) their read methods wouldn't include a `strict` flag and you couldn't pass such objects to functions usin

[Python-ideas] Add function for reading a specific number of bytes/characters from a file object that fails noisily

2022-03-03 Thread Kevin Mills
The code I'm currently working on involves parsing binary data. If I ask for, say, 4 bytes, it's because I actually need 4 bytes and if the file doesn't have 4 bytes for me, it's malformed. Because `f.read(4)` can silently return less than 4 bytes and I don't want to have to explicitly double ch

[Python-ideas] Re: repeat until

2022-03-01 Thread Kevin Mills
If you don't like: while True: ... if whatever: break One thing I've seen people do is: condition = True while condition: ... condition = whatever You can use it if you really hate `while True` loops with `break`. ___ Python-id

[Python-ideas] Re: __name__ for partial functions

2021-09-07 Thread Kevin Mills
I'm not sure what you're proposing. What should its `__name__` be set to? If you have a value you want its `__name__` to be, you can just set it yourself. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ide

[Python-ideas] Re: Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-03 Thread Kevin Mills
As I said before, the "1,2,3" in `f(1,2,3)` has a very different meaning than the "1,2,3" in `d[1,2,3]`. One is a (comma-separated) list of expressions, and one is a single expression, a tuple. `*(1,2,3)` does not evaluate to the tuple `(1,2,3)`, so I don't think expecting it to do so in the co

[Python-ideas] Re: Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-03 Thread Kevin Mills
> One reason MRAB points to. The `*keys` syntax is more-or-less equivalent to > "substitute a tuple" in other Python contexts; you are proposing to give it a > completely different meaning. This would be confusing and inconsistent. I disagree that it is a completely different meaning. If the i

[Python-ideas] Re: Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-01 Thread Kevin Mills
No, definitely not. d[1,2,3] and d[1][2][3] are not the same thing. The latter is what I am talking about. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mail

[Python-ideas] Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-01 Thread Kevin Mills
Given code like this: ``` d = {1: {2: {3: 4}}} print(d[1][2][3]) d[1][2][3] = None print(d) ``` It should be possible to rewrite it using a starred expression, like this: ``` d = {1: {2: {3: 4}}} keys= 1,2,3 print(d[*keys]) d[*keys] = None print(d) ``` Hopefully it's clear from that example wha

[Python-ideas] Re: Method to efficiently advance iterators for sequences that support random access

2020-10-06 Thread Kevin Mills
Sorry for the duplicate message. I realized two seconds after I sent it, that I only replied to you and not the group. I didn't see the `consume` recipe until after I posted, or I probably would've mentioned it. What I want would have to be done in C, because `it_index` (as `listiterobject` and

[Python-ideas] Method to efficiently advance iterators for sequences that support random access

2020-10-05 Thread Kevin Mills
str_iterator, bytes_iterator, range_iterator, list_iterator, and tuple_iterator (and probably others) should have a method that is capable of efficiently advancing the iterator, instead of having to call next repeatedly. I suggest adding an itertools.advance function which dispatches to a dunder

Re: [Python-ideas] PEP draft: context variables

2017-09-05 Thread Kevin Conway
You should add https://bitbucket.org/hipchat/txlocal as a reference for the pep as it largely implements this idea for Twisted. It may provide for some practical discussions of use cases and limitations of this approach. On Tue, Sep 5, 2017, 09:55 Guido van Rossum wrote: > On Tue, Sep 5, 2017 at

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Kevin Conway
As far as providing a thread-local like surrogate for coroutine based systems in Python, we had to solve this for Twisted with https://bitbucket.org/hipchat/txlocal. Because of the way the Twisted threadpooling works we also had to make a context system that was both coroutine and thread safe at th