[Python-Dev] More on contextlib - adding back a contextmanager decorator (original) (raw)
Phillip J. Eby pje at telecommunity.com
Mon May 1 06:17:18 CEST 2006
- Previous message: [Python-Dev] More on contextlib - adding back a contextmanager decorator
- Next message: [Python-Dev] More on contextlib - adding back a contextmanager decorator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 08:08 PM 4/30/2006 -0700, Guido van Rossum wrote:
If you object against the extra typing, we'll first laugh at you (proposals that only shave a few characters of a common idiom aren't all that popular in these parts), and then suggest that you can spell foo.somemethod() as foo().
Okay, you've moved me to at least +0 for dropping context. I have only one object myself that has a non-self context, and it doesn't have a call, so none of my code breaks beyond the need to add parentheses in a few places. ;)
As for decimal contexts, I'm thinking maybe we should have a decimal.using(ctx=None, **kw) function, where ctx defaults to the current decimal context, and the keyword arguments are used to make a modified copy, seems like a reasonable best way to implement the behavior that context was added for. And then all of the existing special machinery can go away and be replaced with a single @contextfactory.
(I think we should stick with @contextfactory as the decorator name, btw, even if we go back to calling enter/exit things context managers.)
- Previous message: [Python-Dev] More on contextlib - adding back a contextmanager decorator
- Next message: [Python-Dev] More on contextlib - adding back a contextmanager decorator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]