boB Stepp <robertvst...@gmail.com> writes: > Under the hood, are the two approaches above done in the same way? I > get your semantics point, but are there two string objects created in > both approaches or does the first in fact create only a single object?
Sometimes, it does. That's an implementation detail, and the behaviour is not guaranteed and can change at any time, even within the exact same program. So it's not something worth considering when writing or reading that code for semantics. > If the first truly only creates a single object, then it seems that > this is a more efficient approach. That's the danger. Consider efficiency of the implementation to be not your job, when learning the language. Far more important are clear expression of intent, and ease of finding errors. -- \ “You can't have everything; where would you put it?” —Steven | `\ Wright | _o__) | Ben Finney _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor