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 t

Re: How to limit *length* of PrettyPrinter

2020-07-25 Thread dn via Python-list
Let me preface this reply with the concern that my level of competence, in this area, is insufficient. However, there are a number of folk 'here' who are 'into' Python's internals, and will (hopefully) jump-in... Also, whilst we appear to be concentrating on understanding the content of a dat

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 th

Re: How to limit *length* of PrettyPrinter

2020-07-23 Thread dn via Python-list
e who 'lurk' on the list - which is fine. Presumably they are able to read contributions and learn from what seems interesting. This behavior is (to me) a major justification for the digest service - not being 'bombarded' by many email msgs is how some voice their

Re: How to limit *length* of PrettyPrinter

2020-07-21 Thread dn via Python-list
On 7/22/20 1:31 PM, Stavros Macrakis wrote: 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, *someth

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: pprint.PrettyPrinter(depth=2,le