19 Jun
2002
19 Jun
'02
6:28 p.m.
def birth(self, name): country = self.countryOfOrigin['name'] return '${name} was born in ${country}'.sub()
now explain why the above is a vast improvement over:
def birth(self, name): country = self.countryOfOrigin['name'] return join(name, ' was born in ', country)
One word: I18n.
(for extra bonus, explain how sub() can be made to execute substantially faster than a join() function)
That's not a requirement. It can obviously be made as fast as the % operator. --Guido van Rossum (home page: http://www.python.org/~guido/)