Unexpected string behaviour: txt = 'this' ' works'

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Feb 11 15:57:31 EST 2009


Jason:
> It's such a minor optimization, that you probably wouldn't see any
> effect on your program.

>>> from dis import dis
>>> def f():
...  return 'This is ' + 'an example.'
...
>>> dis(f)
  2           0 LOAD_CONST               3 ('This is an example.')
              3 RETURN_VALUE

Bye,
bearophile



More information about the Python-list mailing list