On Nov 15, 2019, at 16:07, Danilo J. S. Bellini
wrote:
>
> Hi!
>
> # First simple idea:
>
> TL;DR: Let's show a inspect.Signature instance to the help messages instead
> of just writing its actual "vague" signature [usually (*args, **kwargs)].
But that’s what already happens:
>>> import
Hi!
*# First simple idea:*
TL;DR: Let's show a inspect.Signature instance to the help messages instead
of just writing its actual "vague" signature [usually (*args, **kwargs)].
Suppose we have a decorator that returns a wrapper:
@functools.wraps(func)
def wrapper(*args, **kwargs):
... # som
On Sat, Nov 16, 2019 at 10:21 AM Andrew Barnert wrote:
>
> On Nov 15, 2019, at 14:52, Chris Angelico wrote:
> >
> > On Sat, Nov 16, 2019 at 9:44 AM Oscar Benjamin
> > wrote:
> >>
> >>> On Fri, 15 Nov 2019 at 12:04, Serhiy Storchaka
> >>> wrote:
> >>>
> >>> 15.11.19 12:40, Jonathan Fine пише:
>
On Fri, 15 Nov 2019 at 22:54, Chris Angelico wrote:
>
> On Sat, Nov 16, 2019 at 9:44 AM Oscar Benjamin
> wrote:
> >
> > On Fri, 15 Nov 2019 at 12:04, Serhiy Storchaka wrote:
> > >
> > > 15.11.19 12:40, Jonathan Fine пише:
> > > > The original poster wanted, inside 'with' context management, to o
On Nov 15, 2019, at 14:52, Chris Angelico wrote:
>
> On Sat, Nov 16, 2019 at 9:44 AM Oscar Benjamin
> wrote:
>>
>>> On Fri, 15 Nov 2019 at 12:04, Serhiy Storchaka wrote:
>>>
>>> 15.11.19 12:40, Jonathan Fine пише:
The original poster wanted, inside 'with' context management, to open
On Sat, Nov 16, 2019 at 9:44 AM Oscar Benjamin
wrote:
>
> On Fri, 15 Nov 2019 at 12:04, Serhiy Storchaka wrote:
> >
> > 15.11.19 12:40, Jonathan Fine пише:
> > > The original poster wanted, inside 'with' context management, to open
> > > several files. Context management is, roughly speaking, def
On Fri, 15 Nov 2019 at 12:04, Serhiy Storchaka wrote:
>
> 15.11.19 12:40, Jonathan Fine пише:
> > The original poster wanted, inside 'with' context management, to open
> > several files. Context management is, roughly speaking, deferred
> > execution wrapped in a try ... except statement.
>
>
On 16/11/19 4:30 am, Joao S. O. Bueno wrote:
Just add __enter__ and __exit__ to tuples themselves!
That wouldn't give the same result, though. E.g. if you're
using open(), a failure to open a later file in the list
should trigger the __exit__ of earlier ones. But using
a tuple, all the files ha
Andrew Barnert wrote:
> The advantage of your ExitMap over helper (besides being shorter, and
> conceptually simpler) is that it’s never misleading.
>
[snip]
Thank you for this, particular your example (snipped). I agree. But maybe
I'm biased.
> It still seems like overkill for the case of “how
On Nov 15, 2019, at 04:37, Jonathan Fine wrote:
>
>
> Serhiy suggests
> https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack
> >>> with ExitStack() as stack:
> >>> files = [stack.enter_context(open(fname)) for fname in filenames]
>
> A simpler alternative, for the OP's o
On Fri, Nov 15, 2019, at 10:30, Joao S. O. Bueno wrote:
> Just throwing this idea in: what about an approach _not touching_ the
> parser or compiler at all? :
> Just add __enter__ and __exit__ to tuples themselves! Instead of
> repeating "why should we ever do that", we
> _do_ that exactly to ent
> I think it could also be done by letting the grammar parse it as a tuple
and then having an extra (non-declarative) fixup step. But that obviously
makes parsing more complicated to think through, and to document, etc.
Just throwing this idea in: what about an approach _not touching_ the
parser o
I thank Chris and Serhiy for their helpful comments. I agree with both of
you, that a lambda won't be able to give the desired result. However,
although flawed the idea was a useful stepping stone for me. Perhaps as
"the simplest thing that could possibly work".
I thank Serhiy for saying that
>>>
15.11.19 12:40, Jonathan Fine пише:
The original poster wanted, inside 'with' context management, to open
several files. Context management is, roughly speaking, deferred
execution wrapped in a try ... except statement.
In case of open() there is no deferred execution. The resource is
ac
On Fri, Nov 15, 2019 at 9:41 PM Jonathan Fine wrote:
>
> Hi All
>
> The original poster wanted, inside 'with' context management, to open several
> files. Context management is, roughly speaking, deferred execution wrapped in
> a try ... except statement.
>
> The lambda construction also pr
Hi All
The original poster wanted, inside 'with' context management, to open
several files. Context management is, roughly speaking, deferred execution
wrapped in a try ... except statement.
The lambda construction also provides for deferred execution. Perhaps
something like
>>> with hel
16 matches
Mail list logo