-
Notifications
You must be signed in to change notification settings - Fork 104
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
Provide flush() and close() functions #13
Comments
|
I am kind of on the fence about this idea. It seems to me that in every case where you would use Flush certainly wouldn't hurt, though. If I understand the circular-reference-business correctly, it would only happen if one SoundFile referenced another SoundFile, which itself referenced the first one. Not a particularly likely scenario. |
To get a little more concrete, I've created a pull request: #14. Standard file objects have a I agree that a context manager would be the best choice, but sometimes it's impossible (e.g. interactive sessions). The problem with The SoundFile zombie is definitely a problem, but to avoid usage afterwards, I removed all attributes in my example implementation. So no matter what you try to do, you will get some error message. BTW, there is a little bug in the current implementation: If there is an error in |
This is continued in #14 |
I think both actions should be easily available to the user.
Currently this is done in
__del__()
which might not be that obvious (and flushing cannot be done on its own).__del__()
and__exit__()
could then just simply callclose()
.I don't know if
__del__()
is a bad thing because I don't understand all this circular-reference-business described there: http://docs.python.org/3.3/reference/datamodel.html#object.__del__The text was updated successfully, but these errors were encountered: