Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 8 function names: asdict -> as_dict, astuple -> as_tuple #110

Closed
ericvsmith opened this issue Dec 3, 2017 · 8 comments
Closed

PEP 8 function names: asdict -> as_dict, astuple -> as_tuple #110

ericvsmith opened this issue Dec 3, 2017 · 8 comments

Comments

@ericvsmith
Copy link
Owner

ericvsmith commented Dec 3, 2017

No description provided.

@ilevkivskyi
Copy link
Contributor

ilevkivskyi commented Dec 3, 2017

I don't think this improves readability. I would even say that using underscores in such short names looks a bit weird.

@warsaw
Copy link

warsaw commented Dec 3, 2017

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.

@gvanrossum
Copy link

gvanrossum commented Dec 4, 2017

@hynek
Copy link

hynek commented Dec 4, 2017

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.

@ericvsmith
Copy link
Owner Author

ericvsmith commented Dec 4, 2017

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.

@ericvsmith
Copy link
Owner Author

ericvsmith commented Dec 4, 2017

PEP updated.

@alexmojaki
Copy link

alexmojaki commented Jun 7, 2018

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.

@ericvsmith
Copy link
Owner Author

ericvsmith commented Jun 7, 2018

We wouldn't want to have two names for the same thing. It adds confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants