Re: Elegant hack or gross hack? TextWrapper and escape codes

2020-05-28 Thread Peter Otten
Chris Angelico wrote: > On Thu, May 28, 2020 at 5:54 PM Peter Otten <__pete...@web.de> wrote: >> But at least now you have two -- elegant or gross -- hacks to choose from >> ;) >> > > Yeah, I thought of this originally as a challenge in redefining the > concept of "length". But the trouble is th

Re: Elegant hack or gross hack? TextWrapper and escape codes

2020-05-28 Thread Chris Angelico
On Thu, May 28, 2020 at 5:54 PM Peter Otten <__pete...@web.de> wrote: > > Chris Angelico wrote: > > > Situation: A terminal application. Requirement: Display nicely-wrapped > > text. With colour codes in it. And that text might be indented to any > > depth. > > > > label = f"{indent}\U0010cc32{code

Re: Elegant hack or gross hack? TextWrapper and escape codes

2020-05-28 Thread Peter Otten
Chris Angelico wrote: > Situation: A terminal application. Requirement: Display nicely-wrapped > text. With colour codes in it. And that text might be indented to any > depth. > > label = f"{indent}\U0010cc32{code}\U0010cc00 > @{tweet['user']['screen_name']}: " wrapper = textwrap.TextWrapper( >

Elegant hack or gross hack? TextWrapper and escape codes

2020-05-27 Thread Chris Angelico
Situation: A terminal application. Requirement: Display nicely-wrapped text. With colour codes in it. And that text might be indented to any depth. label = f"{indent}\U0010cc32{code}\U0010cc00 @{tweet['user']['screen_name']}: " wrapper = textwrap.TextWrapper( initial_indent=label, subseque