Evaluate once or every time

Chris Angelico rosuav at gmail.com
Fri Feb 24 17:38:13 EST 2023


On Sat, 25 Feb 2023 at 09:36, <avi.e.gross at gmail.com> wrote:
> From what you say, concatenation between visibly adjacent strings is done once when generating bytecode. Using a plus is supposed to be about the same but may indeed result in either an error if you use anything other than a string literal
>
> bad = "hello " str(12)
>
> or you must use something like a "+" to do the concatenation at each run time. Or, weirder, do it manually as :
>

Abuttal is a syntactic feature. It's completely different from string
concatenation. The only similarity is that some forms of addition may
be constant-folded.

ChrisA


More information about the Python-list mailing list