A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ericvsmith/dataclasses/issues/77 below:

Should the replace() function be renamed? · Issue #77 · ericvsmith/dataclasses · GitHub

The name makes sense for namedtuple, where the fields are truly replaced. But now that the function creates a new object using __init__ and not longer has the post-copy functionality, it doesn't really make sense for Data Classes. For example the fact that init=False fields are not copied from the original object makes replace() a name that doesn't really make sense.

attrs calls the equivalent function evolve(), which I don't really like, either. But I don't have a good name to offer up. Maybe I'll leave it replace(), and let python-dev argue about it when I post the PEP there. That should generate a few hundred emails!

For what it's worth, attrs has an API that's similar to namedtuple's replace(). They call that one assoc(), but it's deprecated. I don't think that name makes sense, either.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4