> > * For someone who understands exactly what they are doing, perhaps $ma > > is the intended placeholder -- why force them to uses braces: > > ${ma}ñana. > > It also makes it more difficult to document. IOW, right now the PEP and > the documentation say that the first non-identifier character terminates > the placeholder. How would you word the rules with your change? """Placeholders must be a valid Python identifier (containing only ASCII alphanumeric characters and an underscore). If an unbraced identifier ends with a non-ASCII alphanumeric character, such as the latin letter n with tilde in $mañana, then a ValueError is raised for the specious identifier. > My only problem with that is the interference that the 'mapping' > argument presents. IOW, kwds can't contain 'mapping'. To support a case where both a mapping and keywords are present, perhaps an auxiliary class could simplify matters: def substitute(self, mapping=None, **kwds): if mapping is None: mapping = kwds elif kwds: mapping = _altmap(kwds, mapping) . . . class _altmap: def __init__(self, primary, secondary): self.primary = primary self.secondary = secondary def __getitem__(self, key): try: return self.primary[key] except KeyError: return self.secondary[key] This matches the way keywords are used with the dict(). Raymond
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