[issue33896] Document what components make up the filecmp.cmp os.stat signature.

2020-10-27 Thread Stavros Macrakis
Stavros Macrakis added the comment: I agree completely that the documentation should be more explicit. The concept of "os.stat signature" is not defined anywhere as far as I can tell. The naive reader (like me) might mistakenly assume that the "os.stat signature" is a

Re: Pythonic style

2020-09-23 Thread Stavros Macrakis
Thanks, Chris, for the useful comments. Comments in line (with snipping of unnecessary content): > > some more variants which *don't* use tuple unpacking, on the theory > that the coding patterns may be useful in > > other cases where unpacking doesn't apply. > > When doesn't it apply? Can you

Re: Pythonic style

2020-09-22 Thread Stavros Macrakis
Thanks to everyone for the comments, especially Tim Chase for the simple and elegant tuple unpacking solution, and Léo El Amri for the detailed comments on the variants. Below are some more variants which *don't *use tuple unpacking, on the theory that the coding patterns may be useful in other

Re: Pythonic style

2020-09-21 Thread Stavros Macrakis
Thanks, Tim! I didn't realize that you could write (x,) on the LHS! Very nice, very Pythonic! -s On Mon, Sep 21, 2020 at 9:15 AM Tim Chase wrote: > On 2020-09-20 18:34, Stavros Macrakis wrote: > > Consider a simple function which returns the first element of an >

Pythonic style

2020-09-21 Thread Stavros Macrakis
I'm trying to improve my Python style. Consider a simple function which returns the first element of an iterable if it has exactly one element, and throws an exception otherwise. It should work even if the iterable doesn't terminate. I've written this function in multiple ways, all of which feel

How to cast to a type WAS: How to limit *length* of PrettyPrinter

2020-07-26 Thread Stavros Macrakis
I was a bit unhappy with my convert function: def convert(typ,obj): newobj = typ.__new__(typ,obj) newobj.__init__(obj) return newobj because it called __xxx__ functions, which are supposed to be internal. It was also a surprise that __new__ ignores

Re: How to limit *length* of PrettyPrinter

2020-07-24 Thread Stavros Macrakis
dn, Thanks again. For background, I come from C and Lisp hacking (one of the MIT developers of Macsyma /Maxima ) and also play with R, though I haven't been a professional developer for many years. I know better

How to limit *length* of PrettyPrinter

2020-07-21 Thread Stavros Macrakis
I see how to limit the *depth* in pretty-printing: import pprint pprint.PrettyPrinter(depth=2).pprint(((11,12,13),(21,22,23,(241,242,243),25,26,27))) ((11, 12, 13), (21, 22, 23, (...), 25, 26, 27)) But I would also like to limit the *length, *something like this: