Closed ericvsmith closed 6 years ago
Actually, I agree with @ericvsmith that underscores improve readability, so I'm +1 on as_dict
and as_tuple
. There are a lot of places in the stdlib that use wordswithoutunderscores (e.g. isinstance
) so consistency is more important, but for new APIs, we should use underscore names.
Otoh this is similar to namedtuple._asdict
.
FWIW, I’m a huge fan of underscores and their lack bothers me in asdict. But as Guido points out, we have a precedent and I found it unfortunate/confusing to build an API that has the same name but a different spelling.
Okay, let's leave this as-is, without the underscore. I'll add a note to the PEP that we're choosing consistency with existing APIs as the reason.
PEP updated.
Would it be bad to have an alias as_dict = asdict
? I see this is something that is not generally done in the standard library but I don't know why.
This is not meant to imply that I am bothered by the name asdict
, I'm just wondering why not both.
We wouldn't want to have two names for the same thing. It adds confusion.
I don't think this improves readability. I would even say that using underscores in such short names looks a bit weird.