[Python-ideas] Re: builtins for running context managers

2021-07-17 Thread Stephen J. Turnbull
Thomas Grainger writes: > Right but it's not a status code - it's a callback that you *must* > call OK. Thing is, Serhiy was just saying "hey I did almost exactly that (but minor technical detail)". In your idiomatic usage, 'exit' is almost invisible outside of the wrapped context manager.

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread Thomas Grainger
Right but it's not a status code - it's a callback that you *must* call On Fri, 16 Jul 2021, 17:17 MRAB, wrote: > On 2021-07-16 12:44, Stephen J. Turnbull wrote: > > Thomas Grainger writes: > > > > > Another example, is a cash point (ATM) won't give you your money > > > until you take your

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread MRAB
On 2021-07-16 12:44, Stephen J. Turnbull wrote: Thomas Grainger writes: > Another example, is a cash point (ATM) won't give you your money > until you take your card That ATM is effective in enforcing the desired behavior. In Python you would usually use an exception to force handling.

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread Stephen J. Turnbull
Thomas Grainger writes: > Another example, is a cash point (ATM) won't give you your money > until you take your card That ATM is effective in enforcing the desired behavior. In Python you would usually use an exception to force handling. Returning status codes, or couples of status codes

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread Thomas Grainger
Another example, is a cash point (ATM) won't give you your money until you take your card On Fri, 16 Jul 2021, 09:28 Stephen J. Turnbull, < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Ethan Furman writes: > > > Isn't that javascript? Javascript idioms are not (necessarily) > > Python

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread Stephen J. Turnbull
Ethan Furman writes: > Isn't that javascript? Javascript idioms are not (necessarily) > Python idioms. True, but unless there is (preferably) a Python idiom or one from another language we borrow from at least somewhat frequently, why not adopt the Javascript idiom? Note: I don't think you

[Python-ideas] Re: builtins for running context managers

2021-07-14 Thread Ethan Furman
On 7/13/21 2:20 PM, Thomas Grainger wrote: > On Tue, 13 Jul 2021, 21:31 Ethan Furman, wrote: >> On 7/13/21 12:43 PM, Thomas Grainger wrote: >>> I used the order I did because it's idiomatic to return the value the user needs >>> followed by the value the user wants. >> >> citation? > > Like the

[Python-ideas] Re: builtins for running context managers

2021-07-13 Thread Thomas Grainger
Like the nodeback interface, it's (err, val) On Tue, 13 Jul 2021, 21:31 Ethan Furman, wrote: > On 7/13/21 12:43 PM, Thomas Grainger wrote: > > > I used the order I did because it's idiomatic to return the value the > user needs > > followed by the value the user wants. > > citation? > > -- >

[Python-ideas] Re: builtins for running context managers

2021-07-13 Thread Ethan Furman
On 7/13/21 12:43 PM, Thomas Grainger wrote: > I used the order I did because it's idiomatic to return the value the user needs > followed by the value the user wants. citation? -- ~Ethan~ ___ Python-ideas mailing list -- python-ideas@python.org To

[Python-ideas] Re: builtins for running context managers

2021-07-13 Thread Thomas Grainger
also https://www.python.org/dev/peps/pep-0343/ probably needs updating - but I'm not sure exactly what the code is ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: builtins for running context managers

2021-07-13 Thread Thomas Grainger
I used the order I did because it's idiomatic to return the value the user needs followed by the value the user wants. On Tue, 13 Jul 2021, 20:24 Serhiy Storchaka, wrote: > 13.07.21 18:59, Thomas Grainger пише: > > given that it's hard to implement this correctly I think there should be > a

[Python-ideas] Re: builtins for running context managers

2021-07-13 Thread Serhiy Storchaka
13.07.21 18:59, Thomas Grainger пише: > given that it's hard to implement this correctly I think there should be a > builtins.enter and builtins.aenter for use like this: > > > ``` > @dataclasses.dataclass > class WrapCmgr: > _cmgr: ContextManager[T] > > def __enter__(self) ->