[Python-Dev] Proposed changes to PEP 343
eric.nieuwland at xs4all.nl
Fri Oct 7 16:21:37 CEST 2005
Nick Coghlan wrote:
> Eric Nieuwland wrote:
>> What happens to
>> with 40*13+2 as X:
>> print X
> It would fail with a TypeError because the relevant slot in the type
> was NULL - the TypeError checks aren't shown for simplicity's sake.
> This behaviour isn't really any different from the existing PEP 343 -
> the only
> difference is that the statement looks for a __with__ slot on the
> EXPR, rather than looking directly for an __enter__ slot.
Hmmm I hadn't noticed that.
In my memory a partial implementation of the protocol was possible.
Thus, __enter__/__exit__ would only be called if they exist.
Oh well, I'll just add some empty methods.
More information about the Python-Dev