On Mon, May 3, 2021 at 5:37 AM Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:
> > f'{row!X:>8.3f} | {sum(row):>8.3f}'
>
hmm -- this is making me think that maybe we should re-enable sum() for
strings -- with an optimized path, rather than an TypeError.
I understand the lesson
Eric V. Smith writes:
> I don't think you'd want f-strings to hijack that expression because it
> starts with "X". Better to do something like:
>
> f'{row!X:>8.3f} | {sum(row):>8.3f}'
I wondered, is that even possible? OK, I guess you could do it with a
Row(Any) class something like
class
I didn't even realize f'{n for n in row}' was already valid syntax. Since
generator expressions can usually only appear within parentheses, I assumed the
syntax wouldn't conflict with anything because you would need to parenthesize
the generator to make it work. Anyway, now I see that the better
On Mon, May 3, 2021 at 9:41 AM Steven D'Aprano wrote:
> I agree with your general observation, but in the specific case of "do
> this to every element of this iterable", I think that's common enough
> that we should consider building it into the mini-languages used by
> format and f-strings.
Agre
On Sun, May 02, 2021 at 04:30:38PM -0400, Eric V. Smith wrote:
[I suggested]
> >Better to invent a new format code, which I'm going to spell as 'X' for
> >lack of something better, that maps a format specifier to every
> >element of any iterable (not just generator comprehensions):
> >
> > f'{
On 5/2/2021 5:44 AM, Steven D'Aprano wrote:
On Sun, May 02, 2021 at 04:09:21AM -, Valentin Berlier wrote:
Let's say i have a matrix of numbers:
matrix = [[randint(7, 50) / randint(1, 3) for _ in range(4)] for _ in range(4)]
I want to format and display each row so that the columns are nic
On Sun, May 02, 2021 at 04:09:21AM -, Valentin Berlier wrote:
> Let's say i have a matrix of numbers:
>
> matrix = [[randint(7, 50) / randint(1, 3) for _ in range(4)] for _ in
> range(4)]
>
> I want to format and display each row so that the columns are nicely lined
> up. Maybe also displa