Yeah, I'm beginning to see that positional args are going to make it
unworkable. I'll write up another proposal with just normal args and
keyword-only args.
Thanks everyone for your feedback!
Eric
On 3/13/2021 8:19 PM, Matt Wozniski wrote:
Oops, sent a reply too soon.
On Sat, Mar 13, 2021 at 3:14 PM Eric V. Smith <e...@trueblade.com
<mailto:e...@trueblade.com>> wrote:
The thing is, even without being able to switch back and forth
within a single dataclass, you could achieve the same thing with
inheritance:
...
In both cases, you'd get re-ordered fields in __init__, and
nowhere else:
def __init__(c, d, *, a, b, e, f):
repr, comparisons, etc. would still treat them in today's order:
a, b, c, d, e, f.
...
And the same logic would apply to positional argument fields
This seems like another disadvantage of allowing positional-only
arguments. If positional-only fields show up just like keyword fields
in an arbitrary position in the repr, the repr will cease to be a
representation of a call to the dataclass's constructor suitable for
passing to `eval`, as it is today when init-only parameters are not in
use.
~Matt
_______________________________________________
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/NZ7E5NKZLBK6EW243D34F3YGAMFPHUTO/
Code of Conduct: http://python.org/psf/codeofconduct/
--
Eric V. Smith
_______________________________________________
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/BIXFOIPFCGPKZWD37AB3V5UU57NYJOLN/
Code of Conduct: http://python.org/psf/codeofconduct/