[Python-ideas] Re: FEATURE REQUEST: Make `logging` Module more Pythonic
On 08/24, Guido van Rossum wrote: > Because all the git history would be lost, and lots of code would break. > That used to be the case but Git has options around that now. ``--ignore-rev`` and ``--ignore-revs-file`` can be used to point at style changing commits that can be excluded from ``blame``. https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revltrevgt -- Meitham Jamaa http://meitham.com GPG Fingerprint: 8C8E3FC7 signature.asc Description: PGP signature ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UQ34JJDQUBEG2QWO46TBIQZ5777HA67V/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.
``. ``x < y`` => x.update(y) ``x > y`` => y.update(x) ``y << x`` => deepupdate(x, y) ``x >> y`` => deepupdate(y, x) Alex Martelli has an implementation of ``deepupdate`` on https://stackoverflow.com/a/3233356/360362 I think supporting ``z = x op y`` on dicts without thinking carefully about mutability and references will just add a new section to the python gotchas. Meitham On 10/21, brian.sk...@gmail.com wrote: > **Strongly** disagree. I would anticipate using this feature a LOT, and would > be excited to see it added. (I would love to replace things like "d2 = > d1.copy(); d2.update(d3)" with just "d2 = d1 | d3". In-place "d2 |= d3" is > nice in its terseness, but isn't a huge benefit.) But, I completely agree > with the arguments in favor of using "|" from the semantic perspective of the > operation being much more like a set operation, than a list operation. > > Further: One angle I don't think I've read from anyone yet (still catching up > on the thread tho) is the question of the obscurity of "|" vs the commonality > of "+", and how they would likely interact with newcomers. A newcomer is > likely going to use "+" a LOT, in all sorts of different situations. Given > how non-intuitive dict merging can be, I would rather 'd1 + d2' throw a > TypeError than return something unexpected. The more-obscure 'd1 | d2' is > likely only going to be used by people who know how the machinery works and > go searching for a more concise idiom, and who thus are less likely to be > surprised by how it works. > > -Brian > ___ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/JXY3VH3UMVLOXRNDQNKDQDRIWJKISSEU/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Meitham Jamaa http://meitham.com GPG Fingerprint: 8C8E3FC7 signature.asc Description: PGP signature ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HCCIG47U3CTOGCZNEI4ETRREKYGEBZBM/ Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] The @update operator for dictionaries
It might also be worth considering YAML's own dict merge operator, the "<<" operator, as in https://yaml.org/type/merge.html as this is the existing Python's shift operator added to dict and will require no change to the synatx:: a = a << b Meitham On 03/10, Chris Angelico wrote: > On Sun, Mar 10, 2019 at 3:16 AM Jonathan Fine wrote: > > > > Anders Hovmöller wrote: > > > > > I don't understand what you mean. Can you provide examples that show the > > > state of the dicts before and after and what the syntax would be the > > > equivalent of in current python? > > > > If a.__radd__ exists, then > > a += b > > is equivalent to > > a = a.__radd__(b) > > > > Similarly, if a.__iat_update__ exists then > > a @update= b > > would be equivalent to > > a = a.__iat_update__(b) > > > > Here's an implementation > > def __iat_update__(self, other): > > self.update(other) > > return self > > > > Thus, 'b' would be unchanged, and 'a' would be the same dictionary as > > before, but updated with 'b'. > > With something this long, how is it better from just writing: > > a = a.update_with(b) > > ? What's the point of an operator, especially if - by your own > statement - it will backward-incompatibly change the language grammar > (in ways that I've yet to understand, since you haven't really been > clear on that)? > > ChrisA > -- Meitham Jamaa http://meitham.com GPG Fingerprint: 3934D0B2 signature.asc Description: PGP signature ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/