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

Add 'with' statement support #239

Merged
merged 1 commit into from Apr 3, 2015

Conversation

2 participants
@jollyroger
Contributor

jollyroger commented Apr 3, 2015

This allows you to use 'with' statement for your workbook like this:

with xlsxwriter.Workbook('test.xlsx') as workbook:
    worksheet = workbook.add_worksheet()
    ...

The workbook will automatically close when exiting "with" statement scope.

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Apr 3, 2015

Owner

Hi Andrii,

All pull request should first start as an discussion issue see the Contributing Guide. Note: This was highlighted at the top of the Pull Request dialog.

Apart from that this is relatively straightforward and also useful. I was waiting for someone to ask for it before I added it. I'm surprised that no-one asked before now.

It will need a test. I'd suggest adding one to this testcase: test_simple01.py.

I'll make a couple of comments inline as well. After that, if you rebase and re-submit I'll merge it.

Thanks,

John

Owner

jmcnamara commented Apr 3, 2015

Hi Andrii,

All pull request should first start as an discussion issue see the Contributing Guide. Note: This was highlighted at the top of the Pull Request dialog.

Apart from that this is relatively straightforward and also useful. I was waiting for someone to ask for it before I added it. I'm surprised that no-one asked before now.

It will need a test. I'd suggest adding one to this testcase: test_simple01.py.

I'll make a couple of comments inline as well. After that, if you rebase and re-submit I'll merge it.

Thanks,

John

@jmcnamara

View changes

Show outdated Hide outdated dev/docs/source/workbook.rst
@jmcnamara

View changes

Show outdated Hide outdated dev/docs/source/workbook.rst
@jmcnamara

View changes

Show outdated Hide outdated xlsxwriter/workbook.py
Add 'with' statement support
This allows you to use 'with' statement for your workbook like this:

    with xlsxwriter.Workbook('test.xlsx') as workbook:
        worksheet = workbook.add_worksheet()
        ...

The workbook will automatically close when exiting "with" statement scope.
@jollyroger

This comment has been minimized.

Show comment
Hide comment
@jollyroger

jollyroger Apr 3, 2015

Contributor

Thank you, John.

I'm sorry for skipping the discussion step. Though I've seen through the document I jumped straight to code requirements and missed this point.

I added test and did the changes you requested.

Thank you for your time.

Contributor

jollyroger commented Apr 3, 2015

Thank you, John.

I'm sorry for skipping the discussion step. Though I've seen through the document I jumped straight to code requirements and missed this point.

I added test and did the changes you requested.

Thank you for your time.

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Apr 3, 2015

Owner

Hii Adrii,

Thanks for submitting and for taking the time to meet the requirements.

Merging.

John

Owner

jmcnamara commented Apr 3, 2015

Hii Adrii,

Thanks for submitting and for taking the time to meet the requirements.

Merging.

John

jmcnamara added a commit that referenced this pull request Apr 3, 2015

@jmcnamara jmcnamara merged commit 5f7bff6 into jmcnamara:master Apr 3, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jollyroger jollyroger deleted the jollyroger:enter_exit branch Apr 3, 2015

@jollyroger

This comment has been minimized.

Show comment
Hide comment
@jollyroger

jollyroger Apr 3, 2015

Contributor

Thanks, that was fast!

Contributor

jollyroger commented Apr 3, 2015

Thanks, that was fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment