[Python-checkins] python/nondist/sandbox/string alt292.py,1.3,1.4

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Sep 7 07:16:04 CEST 2004


Update of /cvsroot/python/python/nondist/sandbox/string
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3896

Modified Files:
	alt292.py 
Log Message:
Improve function names.

Index: alt292.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/string/alt292.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- alt292.py	7 Sep 2004 04:41:54 -0000	1.3
+++ alt292.py	7 Sep 2004 05:15:57 -0000	1.4
@@ -2,9 +2,9 @@
 
 First, it is now a function and accepts either mappings or keyword arguments:
 
->>> dollarsub('the $xxx and', {'xxx':10})
+>>> simplesub('the $xxx and', {'xxx':10})
 'the 10 and'
->>> dollarsub('the $xxx and', xxx='10')
+>>> simplesub('the $xxx and', xxx='10')
 'the 10 and'
 
 
@@ -12,21 +12,21 @@
 unicode components will cause a unicode output.  This matches the behavior of
 other re and string ops:
 
->>> dollarsub('the $xxx and', xxx='10')
+>>> simplesub('the $xxx and', xxx='10')
 'the 10 and'
->>> dollarsub(u'the $xxx and', xxx='10')
+>>> simplesub(u'the $xxx and', xxx='10')
 u'the 10 and'
->>> dollarsub('the $xxx and', xxx=u'10')
+>>> simplesub('the $xxx and', xxx=u'10')
 u'the 10 and'
->>> dollarsub(u'the $xxx and', xxx=u'10')
+>>> simplesub(u'the $xxx and', xxx=u'10')
 u'the 10 and'
 
 
 Non-strings are coerced to the type of the template:
 
->>> dollarsub('the $xxx and', xxx=10)
+>>> simplesub('the $xxx and', xxx=10)
 'the 10 and'
->>> dollarsub(u'the $xxx and', xxx=10)
+>>> simplesub(u'the $xxx and', xxx=10)
 u'the 10 and'
 
 
@@ -37,7 +37,7 @@
 ... line two
 ... the $@malformed token
 ... line four"""
->>> dollarsub(t, {})
+>>> simplesub(t, {})
 Traceback (most recent call last):
  . . .
 ValueError: Invalid placeholder on line 3:  '@malformed'
@@ -51,7 +51,7 @@
 only accept Python identifiers but have improved error detection:
 
 >>> t = u'Returning $ma\u00F1ana or later.'
->>> dollarsub(t, {})
+>>> simplesub(t, {})
 Traceback (most recent call last):
  . . .
 ValueError: Invalid placeholder on line 1:  u'ma\xf1ana'
@@ -59,11 +59,11 @@
 
 Exercise safe substitution:
 
->>> safedollarsub('$$ $name ${rank}', name='Guido', rank='BDFL')
+>>> safesimplesub('$$ $name ${rank}', name='Guido', rank='BDFL')
 '$ Guido BDFL'
->>> safedollarsub('$$ $name ${rank}')
+>>> safesimplesub('$$ $name ${rank}')
 '$ $name ${rank}'
->>> safedollarsub('$$ $@malformed ${rank}')
+>>> safesimplesub('$$ $@malformed ${rank}')
 Traceback (most recent call last):
  . . .
 ValueError: Invalid placeholder on line 1:  '@malformed'
@@ -101,7 +101,7 @@
 
 del _re
 
-def dollarsub(template, mapping=None, **kwds):
+def simplesub(template, mapping=None, **kwds):
     """A function for supporting $-substitutions."""
     if mapping is None:
         mapping = kwds
@@ -116,7 +116,7 @@
                          (lineno, catchall))
     return _pattern.sub(convert, template)
 
-def safedollarsub(template, mapping=None, **kwds):
+def safesimplesub(template, mapping=None, **kwds):
     """A function for $-substitutions.
 
     This function is 'safe' in the sense that you will never get KeyErrors if



More information about the Python-checkins mailing list