On Wed, Jun 19, 2002 at 09:05:00AM +0200, Fredrik Lundh wrote: > Barry wrote: > > > 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) Assuming join = lambda *args: ''.join(map(str, args)) 1. Friendly for people coming from other languages (Perl/shell). Same reason why the != operator was added as an alternative to <>. 2. Less quotes and commas for the terminally lazy. 3. More flexible for data-driven use. Either the template or the dictionary can be data rather than hard-wired into the code. Oren
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4