Andrew Barnert via Python-ideas writes:
> [A] context manager seems perfect. It allows you to hint any
> statement, including a loop statement, by adding whatever code you
> want that gets run before and after the statement.
I wonder: The analogy "decorator : function :: with : suite" seems
us
Yes
https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator
On Thu, Mar 19, 2020 at 3:26 PM Stephen J. Turnbull <
[email protected]> wrote:
> Andrew Barnert via Python-ideas writes:
>
> > [A] context manager seems perfect. It allows you to hint any
> > st
On Mar 19, 2020, at 06:23, Stephen J. Turnbull
wrote:
>
> Andrew Barnert via Python-ideas writes:
>
>> [A] context manager seems perfect. It allows you to hint any
>> statement, including a loop statement, by adding whatever code you
>> want that gets run before and after the statement.
>
> I
On Mon, 16 Mar 2020 at 22:22, Andrew Barnert via Python-ideas
wrote:
> I think the best solution is to just not have a SortedList. C++, Java, etc.
> don’t provide anything like that
Guava has TreeMultiset:
https://guava.dev/releases/snapshot/api/docs/com/google/common/collect/TreeMultiset.html
On Mar 19, 2020, at 11:29, Marco Sulla wrote:
>
> On Mon, 16 Mar 2020 at 22:22, Andrew Barnert via Python-ideas
> wrote:
>> I think the best solution is to just not have a SortedList. C++, Java, etc.
>> don’t provide anything like that
>
> Guava has TreeMultiset:
> https://guava.dev/releases/
On Thu, Mar 19, 2020 at 11:38:28PM +, Samuel Colvin wrote:
> But it also looks for a "__pretty__" method on objects, and if found uses
> that to display the object.
Are you aware that dunder names are reserved for Python's use?
> The challenge here is that "__pretty__" can't just return a s
On Wed, Mar 18, 2020 at 09:26:52PM -0700, Andrew Barnert via Python-ideas wrote:
> > On Mar 18, 2020, at 04:22, haael wrote:
> >
> > What is bugging me is the assymetry: there is a nice way to hint functions,
> > but there is none to hint loops.
>
> Then Steve’s suggestion of a context manager
On Thu, Mar 19, 2020 at 07:28:56PM +0100, Marco Sulla wrote:
> On Mon, 16 Mar 2020 at 22:22, Andrew Barnert via Python-ideas
> wrote:
> > I think the best solution is to just not have a SortedList. C++, Java, etc.
> > don’t provide anything like that
>
> Guava has TreeMultiset:
> https://guava.d
On Fri, Mar 20, 2020 at 2:59 PM Steven D'Aprano wrote:
>
> On Thu, Mar 19, 2020 at 11:38:28PM +, Samuel Colvin wrote:
>
> > But it also looks for a "__pretty__" method on objects, and if found uses
> > that to display the object.
>
> Are you aware that dunder names are reserved for Python's us
On Fri, Mar 20, 2020 at 03:01:16PM +1100, Chris Angelico wrote:
> On Fri, Mar 20, 2020 at 2:59 PM Steven D'Aprano wrote:
> >
> > On Thu, Mar 19, 2020 at 11:38:28PM +, Samuel Colvin wrote:
> >
> > > But it also looks for a "__pretty__" method on objects, and if found uses
> > > that to display
On Fri, Mar 20, 2020 at 3:28 PM Steven D'Aprano wrote:
>
> On Fri, Mar 20, 2020 at 03:01:16PM +1100, Chris Angelico wrote:
> > On Fri, Mar 20, 2020 at 2:59 PM Steven D'Aprano wrote:
> > >
> > > On Thu, Mar 19, 2020 at 11:38:28PM +, Samuel Colvin wrote:
> > >
> > > > But it also looks for a "_
On Fri, Mar 20, 2020 at 03:37:08PM +1100, Chris Angelico wrote:
> "Subject to breakage without warning" technically applies to a *lot*
> of things that aren't guaranteed.
Yes?
> Using __pretty__ as a protocol is no different from any of those.
If we should choose to use a `__pretty__` dunder,
On 20/03/20 4:55 pm, Steven D'Aprano wrote:
Are you aware that dunder names are reserved for Python's use?
Nobody is going to put you in jail if you use an unofficial dunder
name. You just run the risk that your use of it will conflict with
some official use in the future.
--
Greg
___
On Fri, Mar 20, 2020 at 06:30:24PM +1300, Greg Ewing wrote:
> On 20/03/20 4:55 pm, Steven D'Aprano wrote:
>
> >Are you aware that dunder names are reserved for Python's use?
>
> Nobody is going to put you in jail if you use an unofficial dunder
> name. You just run the risk that your use of it wi
14 matches
Mail list logo