A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088299.html below:

[Python-Dev] Possible py3k io wierdness

[Python-Dev] Possible py3k io wierdness [Python-Dev] Possible py3k io wierdnessGreg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 6 00:39:43 CEST 2009
Brian Quinlan wrote:

>         if not self.__closed:
>             try:
> -                self.flush()
> +                IOBase.flush(self)
>             except IOError:
>                 pass  # If flush() fails, just give up
>             self.__closed = True

That doesn't seem like a good idea to me at all. If
someone overrides flush() but not close(), their
flush method won't get called, which would be surprising.

To get the desired behaviour, you need something like

   def close(self):
     if not self.__closed:
       self.flush()
       self._close()
       self.__closed = True

and then tell people to override _close() rather than
close().

-- 
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4