Thursday, March 31, 2011

every string is an iterable of strings

>>> 'a'[0][0][0][0][0]
'a'
Python does not actually create a bunch of string objects when you do this.

>>> a = 'a'
>>> id(a) == id(a[0][0][0][0])
True

No comments:

Post a Comment