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

Comments

@ericvsmith
Copy link
Owner

@ericvsmith ericvsmith commented Dec 3, 2017

No description provided.

@ilevkivskyi

This comment has been minimized.

Copy link
Contributor

@ilevkivskyi 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

This comment has been minimized.

Copy link

@warsaw 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

This comment has been minimized.

Copy link

@gvanrossum gvanrossum commented Dec 4, 2017

@hynek

This comment has been minimized.

Copy link

@hynek 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

This comment has been minimized.

Copy link
Owner Author

@ericvsmith 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

This comment has been minimized.

Copy link
Owner Author

@ericvsmith ericvsmith commented Dec 4, 2017

PEP updated.

@ericvsmith ericvsmith closed this Dec 4, 2017
@alexmojaki

This comment has been minimized.

Copy link

@alexmojaki 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

This comment has been minimized.

Copy link
Owner Author

@ericvsmith 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
Projects
None yet
6 participants
You can’t perform that action at this time.