Chris Angelico writes:
> Using popitem mutates the underlying dict. That's a tad more likely
> to affect other parts of the code.
Granted. The context is opposition to itertools.first. "Advocating"
popitem is tongue-in-cheek, with the serious point is that it's
obvious that it alters state
For StreamRequetHandler's rfile attribute, it will block when the read readline
readlines reach the end.
It would be nice to add non-blocking read because the seek() is unavailable for
rfile. and there is no other way to detect if it is ended.
When the stream is empty and waiting for new
>
> here is the thread from the last time that this was brought up:
>
> https://mail.python.org/archives/list/python-ideas@python.org/thread/S7UMTWK65X6BJDYZ3SSU7I7HOIASDMMJ/#S7UMTWK65X6BJDYZ3SSU7I7HOIASDMMJ
Thanks, that's very helpful. Sounds like Guido is right, and the short
answer is "while
Thank you for the feedback. I was unaware of the packaging package and PEP
440. I recognize that there are definitely some problems with my idea.
I took a look at the packaging package, and I think it might be a good idea
to put something like it in the stdlib. The Version type there from what I
here is the thread from the last time that this was brought up:
https://mail.python.org/archives/list/python-ideas@python.org/thread/S7UMTWK65X6BJDYZ3SSU7I7HOIASDMMJ/#S7UMTWK65X6BJDYZ3SSU7I7HOIASDMMJ
It was very thoroughly discussed then.
-CHB
On Sun, Oct 10, 2021 at 8:33 AM Guido van Rossum
You have to check the C code to be sure, but IIRC the latest dict
implementation has a dense array of the values in insert order, and the
hash table (which has gaps) contains indexes into the values array. So you
could easily index into the values array (which I believe also has the
keys) in O(1)
> Should `dict.items()` be indexable now that dicts are ordered? I say yes. Why
> shouldn't it?
Would there be a way to ensure that this had the same time complexity as
indexing of sequences? If "yes", I would support this — I think it would be
useful in some situations, and it would be more
> The problem is that first() does not return the first item of the
> iterator, but the *next item still available*.
>
>a = list('12345')
>b = iter('12345')
>
>first(a) == first(a) # True
>first(b) == first(b) # False
This is an excellent point, and something I hadn't
On Mon, Oct 11, 2021 at 12:17 AM Stephen J. Turnbull
wrote:
>
> Steven D'Aprano writes:
> > On Sun, Oct 10, 2021 at 01:51:52AM +0900, Stephen J. Turnbull wrote:
> > > Christopher Barker writes:
> > >
> > > > But last time, one of the use cases was "get [an arbitrary] item
> > > > from a
On Sat, Oct 09, 2021 at 08:16:58PM -0600, Finn Mason wrote:
> I feel like there could be a better way to define versions. There's no real
> standard way to specify versions in Python, other than "use semantic
> versioning."
It is a common myth that Python uses semantic versioning. It doesn't.
Steven D'Aprano writes:
> On Sun, Oct 10, 2021 at 01:51:52AM +0900, Stephen J. Turnbull wrote:
> > Christopher Barker writes:
> >
> > > But last time, one of the use cases was "get [an arbitrary] item
> > > from a dict", and there really is not a terribly easy (and
> > > efficient) way
On Sat, Oct 09, 2021 at 08:16:58PM -0600, Finn Mason wrote:
> import sys
> if sys.version_info < (3, 6):
> # Yell at the user
Please, version checking is usually an anti-pattern! You should use
feature detection whenever possible, not version checking.
For example, if you need the lcm
Over the past few weeks/months I have had on an off issues with the way python
handles class-attributes. Consider the default way to do it:
```
class A:
attr = 2
"""Docstring of the attribute"""
```
There are 2 main issues I have with this way of setting class-attributes:
1. It does
On Sun, 10 Oct 2021 at 05:06, Finn Mason wrote:
>
> Let's get back to the original topic. Should `dict.items()` be indexable now
> that dicts are ordered? I say yes. Why shouldn't it?
I say no.
"Why shouldn't it?" isn't sufficient justification for a change.
Because it costs someone time and
On Sun, 10 Oct 2021 at 03:20, Finn Mason wrote:
>
> Hello all,
>
> I was thinking about the following idioms:
>
> __version__ = "1.0"
>
> import sys
> if sys.version_info < (3, 6):
> # Yell at the user
>
>
> I feel like there could be a better way to define versions. There's no real
>
15 matches
Mail list logo