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

proposal: return value for openpyxl.worksheet.worksheet.append() #61

Open
MaykGyver opened this issue Aug 12, 2024 · 0 comments
Open

proposal: return value for openpyxl.worksheet.worksheet.append() #61

MaykGyver opened this issue Aug 12, 2024 · 0 comments

Comments

@MaykGyver
Copy link

given

openpyxl.worksheet.worksheet.append(iterable) returns None

proposal

openpyxl.worksheet.worksheet.append(iterable) returns a list or dict. If iterable was a list, return the list of cells appended matching the order of items. If iterable was a dict, return a dict of cells appended matching the keys of the items.

reasoning

The existing append function works out in 95% of the cases – fire and forget. But in some cases, you want some additional action on the appended cells like formatting or adding a hyperlink. Either you waive your additional requirements or you reimplement append logic to get the appended cells. Not very pythonic.

The proposed extension should not have severe impact on performance since the cells are touched during runtime in a similar manner as returned anyways. No extra loops and no extra objects except the "offer" towards the caller. If the return value is not consumed, it will be garbaged almost immediately. If the return value is consumed, it avoids inefficient workaround implementations by the consumer.

The proposal is backwards compatible since nobody should've used None.

miscellaneous

If the community accepts the proposal but doesn't feel like implementing with all bells and whistles, I'd be happy to assist.

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

1 participant