On Tue, 18 Jun 2002, Barry A. Warsaw wrote: > def birth(self, name): > country = self.countryOfOrigin['name'] > return '${name} was born in ${country}' > > birth('Guido') > > returns > > 'Guido was born in the Netherlands' I assume you in fact meant return '${name} was born in ${country}'.sub() for the third line above? > print s.sub({'name': 'Guido', > 'country': 'the Netherlands'}) Have you considered the possibility of accepting keyword arguments instead? They would be slightly more pleasant to write: print s.sub(name='Guido', country='the Netherlands') This is motivated because i imagine relative frequencies of use to be something like this: 1. sub() [most frequent] 2. sub(name=value, ...) [nearly as frequent] 3. sub(dictionary) [least frequent] If you decide to use keyword arguments, you can either allow both keyword arguments and a single dictionary argument, or you can just accept keyword arguments and people can pass in dictionaries using **. -- ?!ng
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