Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Doesn't necessarily have to be in an invalid state. You can have your object with a none value for the socket or a state like "not_started" and the different method will look at that to handle everything properly.

Also, it was not supposed to be used in a context manager as there is just a close method but it is the caller that decided to wrap it in a context.

But as what you suggest, indeed it would have been a great idea to add an __enter__ and do the starting there are as it would be the proper way.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: