[Tutor] Proxies/Interceptors for file-like objects
Lie Ryan
lie.1296 at gmail.com
Thu Feb 19 12:03:24 CET 2009
On Thu, 19 Feb 2009 20:12:57 +1100, Oxymoron wrote:
> Thanks for the answers everyone.
>
> Denis, I wish to wrap an already open file handle basically, so simply
> extending and overriding doesn't help - my proxy won't be instantiated
> like a file, just used like one and if not intercepting I need to
> delegate down to the proxied "real" handle. If I'm missing something,
> please let me know. Here's the actual scenario:
>
If you replace sys.stdin with your own file object, you don't need to
define all of the file object interface, just the one that generates an
error if not defined (i.e. the ones that you use).
Alternatively, you may also consider using subprocess.
More information about the Tutor
mailing list