Skip to content
Discussion options

You must be logged in to vote

You appear to be wanting to close a file you've opened for writing at the app level, it's not clear to me why you wouldn't simply call close on the resulting handle. As for how and where you'd do that: it's also unclear to me why you'd open it at the app level, but then want to close it down at an individual widget level.

I'm still not really clear what it is you're asking or why the mention of context managers and with; but given the code you've shown, suggesting you want a resource open for the lifetime of the application and you want to tidy up when you leave, honestly I think I'd personally create/clean outside of the application. For example:

from io import TextIOWrapper
from textual i…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@iscas-zac
Comment options

@davep
Comment options

Comment options

You must be logged in to vote
5 replies
@davep
Comment options

@iscas-zac
Comment options

@davep
Comment options

Answer selected by iscas-zac
@iscas-zac
Comment options

@iscas-zac
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants