3 ms·
> Eager lists have their place! Ya can't sort or slice into a generator. I like the choice. Something like that could be handled implicitly... hmm but that see
by DonaldPShimoda 8y ago
> Eager lists have their place! Ya can't sort or slice into a generator. I like the choice.
Something like that could be handled implicitly... hmm but that seems bad. Maybe you're right that having a choice is better!
> I can do "%s %s %s" % (a.b(), z[:4], x2) without binding new variables. Can f strings do that? I don't know.
In 3.x f-string style, `f"{a.b()} {z[:4]} {x2}"` would work just fine! Python just expects any expression inside the curly braces, so as long as you give up a value (and that value is either a string or an object of a class that implements `__str__`, I think), you're golden.
It's particularly useful when you have a lot of interpolation to do. The more arguments there are, the more tedious it is to read through a %-style format and figure out which variables correspond to what markers in the string.
> I agree about the whitespace issues. Have you seen a language do them better?
Not really, unfortunately.
I think a case could be made that all indentation should be based on either (a) the triple-quote or (b) the first non-whitespace character of the first line. But I don't know if that's intuitive enough. Definitely something to think about, though!