Has anyone mentioned the IPython pretty printer yet? I'm late to the
conversation unfortunately, so apologies if someone else already raised it.
https://ipython.readthedocs.io/en/stable/api/generated/IPython.lib.pretty.html#IPython.lib.pretty.pretty
On Fri, 20 Mar 2020 at 16:02, wrote:
> Send Py
Steve Jorgensen wrote:
> Based on the conversations stemming from my previous post, it is clear that
> the topic
> was too implementation-specific. It is not clear whether dunder methods are
> an appropriate
> component of the solution (they might or might not be).
> Also, it presumably makes sen
On 3/16/2020 1:15 PM, Steve Jorgensen wrote:
Steve Jorgensen wrote:
Based on the conversations stemming from my previous post, it is clear that the
topic
was too implementation-specific. It is not clear whether dunder methods are an
appropriate
component of the solution (they might or might no
Hi,
I understand that the default implementation of heapq.heapify is to create a
min-heap. The logic for max-heapify has already been implemented inside
_heapify_max and along with that for corresponding push and pop operations. But
they are not exposed to the user and hence not mentioned in any
It is easy to have a wrapper class around the heapq functions so that you
can use
an arbitrary comparison on the heap.
I have an answer with such an snippet, that got some
activity today - maybe exactly due to your questioning:
https://stackoverflow.com/questions/8875706/heapq-with-custom-compare
On Fri, 20 Mar 2020 at 05:06, Steven D'Aprano wrote:
> On Thu, Mar 19, 2020 at 07:28:56PM +0100, Marco Sulla wrote:
> > The problem is: is there a use case? I mean, how much time you need to
> > sort a list, add an element and re-sort it?
> Depends on whether you are adding and re-sorting *one* el
Hi Steven,
> Are you aware that dunder names are reserved for Python's use?
I wasn't aware it was explicitly discouraged, thanks for the link.
It seems to me that "__pretty__" (however it's implemented) seems a very
sensible name for a method used when pretty printing objects. If it's one
day im
It’s a bit ironic: if you have a nifty idea for Python, you are often told
to try it out on your own. And if you expect it to maybe make its way into
Python, you’d want to use a dunder...
But then, dunders are reserved for the standard library. It’s a pickle.
And it’s not like there’s no preceden
Steven D'Aprano writes:
> Wasn't me, it was the other Stephen who spells his name with a "ph"
> :-)
Guilty as charged, on both counts.
> So each loop will need its own context manager, meaning its own
> class. The *actual* invariant will be buried far away, in a CM
> class, rather than righ
Samuel Colvin writes:
> Hi Steven,
>
> > Are you aware that dunder names are reserved for Python's use?
>
> I wasn't aware it was explicitly discouraged, thanks for the link.
>
> It seems to me that "__pretty__" (however it's implemented) seems a very
> sensible name for a method used wh
Steven D'Aprano wrote:
> Yes, really.
>
>
https://docs.python.org/3/reference/lexical_analysis.html#reserved-classes-of-identifiers
I remembered the existence of this rule and tried to locate it recently
(prior to this discussion), but was unable to because it doesn't explicitly
mention "dunder".
On Sat, Mar 21, 2020 at 12:16:29PM +0900, Stephen J. Turnbull wrote:
> The way I think of pprint (FWIW, YMMV) is as a debug utility.
Oh, that's interesting. I mostly think of pretty-printing as a display
utility aimed at end users.
--
Steven
___
Py
12 matches
Mail list logo