On 1/10/2011 11:51 AM, Emile van Sebille wrote:

well, not predictably unless you understand the specifics of the implementation you're running under.


>>> from string import letters
>>> longstring = letters*100
>>> otherstring = letters*100
>>> id(longstring)
12491608
>>> id (otherstring)
12100288
>>> shortstring = letters[:]
>>> id(letters)
11573952
>>> id(shortstring)
11573952
>>>

In my experiment I found that using * to replicate gave different results than using the exact literal. That is why in the program I posted I used the equivalent of eval("'" + letters*n + "'") which gives different results than eval("letters*n")!

[snip]

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to