[Python-Dev] Proposed changes to PEP 343

Michael Hudson mwh at python.net
Fri Oct 7 15:02:12 CEST 2005


Nick Coghlan <ncoghlan at gmail.com> writes:
> What if we simply special-cased the __with__ slot in type(), such that if it 
> is populated with a generator object, that object is automatically wrapped 
> using the @contextmanager decorator? (Jason actually suggested this idea 
> previously)

<nit>
You don't want to check if it's a generator, you want to check if it's
a function whose func_code has the relavent bit set.
</nit>
Seems a bit magical to me, but haven't thought about it hard.
Cheers,
mwh
-- 
 I think my standards have lowered enough that now I think ``good
 design'' is when the page doesn't irritate the living fuck out of 
 me. -- http://www.jwz.org/gruntle/design.html


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /