I can't say how much of a nice improve removeprefix() and removesuffix() is. lstrip and rstrip prefix and suffix trimming bugs crop up in people's code constantly. This seems like a nice change, especially since the alternatives are so ugly.
I can't say how much of a nice improve removeprefix() and removesuffix() is. lstrip and rstrip prefix and suffix trimming bugs crop up in people's code constantly. This seems like a nice change, especially since the alternatives are so ugly.
{**a, **b}
You could see this as an improvement.The dict literal with dict-splats conveys a sense of ordering that makes the behavior of taking values for overlapping keys from the lattermost dict make more sense to me.
I'm also a fan of the walrus operator. These are small, rare, clear, useful, idiomatic new features, in my opinion.
One frets that Python could become a victim of 'featuritis' as the devs try to shop for a new kitchen sink for each release.
But of course, both are very welcomed!
What do you mean by that? Can't we clear a list by doing:
L[:] = []
(useful when L is defined in another scope, or when you want to keep a reference to the same list object)Unfortunately it's not possible to search for "[:]", so pointers appreciated
L[1:] = [] if "foobar".startswith("foo"): "foobar"[len("foo"):] > "foobar".lstrip("foo")
"bar"
Of course, if the developer making this mistake tested with "foofbar" instead then they would realise their mistake. A more typical example of this type of mistake would be url.lstrip("http://"). > "foobar".lstrip("wooowweeezoweeef")
bar >>> "foobarbaz".lstrip("fo")
'barbaz'