summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
Commit message (Collapse)AuthorAgeFilesLines
* #13579: minimize code base drift for 'a' string.Formatter change.R David Murray2012-08-191-4/+4
| | | | | | 2.7 doesn't support 'a'. This changeset ports the doc change and clause-reording portions of Francisco Martín Brugué patch in order to minimize code base drift.
* Merged revisions 84470-84471,84566-84567,84759 via svnmerge fromFlorent Xicluna2010-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84470 | florent.xicluna | 2010-09-03 22:00:37 +0200 (ven., 03 sept. 2010) | 1 line Strengthen BytesWarning tests. ........ r84471 | florent.xicluna | 2010-09-03 22:23:40 +0200 (ven., 03 sept. 2010) | 1 line Typo ........ r84566 | florent.xicluna | 2010-09-06 22:27:15 +0200 (lun., 06 sept. 2010) | 1 line typo ........ r84567 | florent.xicluna | 2010-09-06 22:27:55 +0200 (lun., 06 sept. 2010) | 1 line typo ........ r84759 | florent.xicluna | 2010-09-13 04:28:18 +0200 (lun., 13 sept. 2010) | 1 line Reenable test_ucs4 and remove some duplicated lines. ........
* Issue5416 - Revert a documentatin change made to explain replace on negative ↵Senthil Kumaran2010-09-081-6/+5
| | | | | | value. Minor changes to doc: s/maxsplit/maxreplace
* Fix Issue5416 - explain negative value of maxplit in str.replace.Senthil Kumaran2010-08-091-1/+2
|
* #7000: document "sep" in capwords. Add a few testsEzio Melotti2009-09-261-4/+6
|
* fix commentBenjamin Peterson2008-11-091-3/+2
|
* Replace all map(None, a) with list(a).Georg Brandl2008-07-181-1/+1
|
* Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith2008-02-171-0/+112
| | | | | | | | | | | | | | | Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
* SF 1193128: Let str.translate(None) be an identity transformationRaymond Hettinger2007-04-121-1/+1
|
* Add a type.__init__() method that enforces the same signature asGuido van Rossum2007-03-231-3/+1
| | | | | | | | | type.__new__(), and then calls object.__init__(cls), just to be anal. This allows us to restore the code in string.py's _TemplateMetaclass that called super(...).__init__(name, bases, dct), which I commented out yesterday since it broke due to the stricter argument checking added to object.__init__().
* - Bug #1683368: The object.__init__() and object.__new__() methods areGuido van Rossum2007-03-231-1/+3
| | | | | | | | | | | | | now stricter in rejecting excess arguments. The only time when either allows excess arguments is when it is not overridden and the other one is. For backwards compatibility, when both are overridden, it is a deprecation warning (for now; maybe a Py3k warning later). When merging this into 3.0, the warnings should become errors. Note: without the change to string.py, lots of spurious warnings happen. What's going on there?
* Cookie.py shouldn't "bogusly" use string._idmap.Georg Brandl2006-08-141-1/+0
|
* Fix bug in passing tuples to string.Template. All other values (with workingThomas Wouters2006-07-051-3/+3
| | | | | | | | | | | | | | str() or repr()) would work, just not multi-value tuples. Probably not a backport candidate, since it changes the behaviour of passing a single-element tuple: >>> string.Template("$foo").substitute(dict(foo=(1,))) '(1,)' versus '1'
* Remove outdated references to the regsub module.Raymond Hettinger2004-12-071-3/+2
|
* SF patch #1056967, changes the semantics of Template.safe_substitute() to notBarry Warsaw2004-11-011-1/+1
| | | | raise a ValueError for dangling delimiters (the delimiter itself is returned).
* Invalid patterns to substitute and safe_substitute would crash since patternNeal Norwitz2004-10-171-2/+4
| | | | is not a local variable. Add a test case.
* Make the regex pattern easier to read, understand, and modifyRaymond Hettinger2004-09-261-4/+6
| | | | by factoring out the common prefix (the delimiter).
* At the cost of a modest (but useful in its own right) change in the semanticsBarry Warsaw2004-09-181-8/+6
| | | | | | | | | of the Template.delimiter attribute, we make use of the delimiter in the escaped group, and in the safe_substitute() method more robust. Now, .delimiter should be the unescaped delimiter literal, e.g. '$' or '&', or whatever. The _TemplateMetaclass will re.escape() this value when it builds the pattern.
* Whitespace normalization.Tim Peters2004-09-161-1/+1
|
* Make the hint about the None default less ambiguous.Walter Dörwald2004-09-141-1/+1
|
* Enhance the docstrings for unicode.split() and string.split()Walter Dörwald2004-09-141-1/+1
| | | | | to make it clear that it is possible to pass None as the separator argument to get the default "any whitespace" separator.
* Fix small bugs in Template code.Raymond Hettinger2004-09-141-7/+12
| | | | | | | | | | | | | | * The parameterization of "delimiter" was incomplete. * safe_substitute's code for braced delimiters should only be executed when braced is not None. * Invalid pattern group names now raise a ValueError. Formerly, the convert code would fall off the end and improperly return None. Beefed-up tests. * Test delimiter override for all paths in substitute and safe_substitute. * Alter unittest invocation to match other modules (now it itemizes the tests as they are run).
* Raymond's good suggestion to re-order the tests in the convert() helper so theBarry Warsaw2004-09-131-13/+16
| | | | | most common paths are tested first. Also, that 'invalid' is better than 'bogus'.
* substitute(), safe_substitute(): Paul Moore provides a better hack for dealingBarry Warsaw2004-09-131-11/+19
| | | | with positional arguments.
* Accepted Raymond's patch to combine mapping and keyword arguments, with slightBarry Warsaw2004-09-131-5/+32
| | | | | modification. Also, renamed the positional argument to '__mapping' to further reduce the chance of duplicate keyword arguments.
* Template: remove __slots__ since that interferes with the ability to mix inBarry Warsaw2004-09-101-1/+0
| | | | Template and unicode classes.
* __slots__ went missing from Template.Raymond Hettinger2004-09-101-0/+1
|
* Many updates to PEP 292 templates. Summary:Barry Warsaw2004-09-101-31/+54
| | | | | | | | | | | | | | | | | - Template no longer inherits from unicode. - SafeTemplate is removed. Now Templates have both a substitute() and a safe_substitute() method, so we don't need separate classes. No more __mod__() operator. - Adopt Tim Peter's idea for giving Template a metaclass, which makes the delimiter, the identifier pattern, or the entire pattern easy to override and document, while retaining efficiency of class-time compilation of the regexp. - More informative ValueError messages which will help a user narrow down the bogus delimiter to the line and column in the original string (helpful for long triple quoted strings).
* Minor improvements to the template code.Raymond Hettinger2004-08-261-18/+15
| | | | | | | | * Add comment bars segregating this code from the rest. * Improve readability of the re pattern with indentation and comments on the same line. * Replace the groupdict() and get() pair with a direct call to group() which does the same thing.
* PEP 292 classes Template and SafeTemplate are added to the string module.Barry Warsaw2004-08-251-34/+106
| | | | | | | | This patch includes test cases and documentation updates, as well as NEWS file updates. This patch also updates the sre modules so that they don't import the string module, breaking direct circular imports.
* Add rsplit method for str and unicode builtin types.Hye-Shik Chang2003-12-151-0/+12
| | | | | SF feature request #801847. Original patch is written by Sean Reifschneider.
* Add optional fillchar argument to ljust(), rjust(), and center() string methods.Raymond Hettinger2003-11-261-12/+12
|
* tweak the docstring to not be so focused on 1.6.Skip Montanaro2003-10-031-5/+5
|
* Attempt to make all the various string *strip methods the same.Neal Norwitz2003-04-101-9/+10
| | | | | | | | | | | * Doc - add doc for when functions were added * UserString * string object methods * string module functions 'chars' is used for the last parameter everywhere. These changes will be backported, since part of the changes have already been made, but they were inconsistent.
* Update the docstring to match the code. Will backport.Neal Norwitz2002-11-141-1/+3
|
* Make strip behave as documented. Will backport to 2.2.3.Martin v. Löwis2002-11-081-2/+2
|
* Convert empty string literal to string. Speed up creation of idmap.Martin v. Löwis2002-10-141-3/+4
|
* Remove uses of the string and types modules:Walter Dörwald2002-06-031-5/+1
| | | | | | | | | | | | | | | | | | | | | | x in string.whitespace => x.isspace() type(x) in types.StringTypes => isinstance(x, basestring) isinstance(x, types.StringTypes) => isinstance(x, basestring) type(x) is types.StringType => isinstance(x, str) type(x) == types.StringType => isinstance(x, str) string.split(x, ...) => x.split(...) string.join(x, y) => y.join(x) string.zfill(x, ...) => x.zfill(...) string.count(x, ...) => x.count(...) hasattr(types, "UnicodeType") => try: unicode except NameError: type(x) != types.TupleTuple => not isinstance(x, tuple) isinstance(x, types.TupleType) => isinstance(x, tuple) type(x) is types.IntType => isinstance(x, int) Do not mention the string module in the rlcompleter docstring. This partially applies SF patch http://www.python.org/sf/562373 (with basestring instead of string). (It excludes the changes to unittest.py and does not change the os.stat stuff.)
* Apply the second version of SF patch http://www.python.org/sf/536241Walter Dörwald2002-04-151-8/+6
| | | | | | | | | | Add a method zfill to str, unicode and UserString and change Lib/string.py accordingly. This activates the zfill version in unicodeobject.c that was commented out and implements the same in stringobject.c. It also adds the test for unicode support in Lib/string.py back in and uses repr() instead() of str() (as it was before Lib/string.py 1.62)
* [Bug #536241] string.zfill() produces mangled output for a Unicode string.Andrew M. Kuchling2002-03-291-8/+8
| | | | | | | | | | | | | | | Walter Doerwald provided a patch, which I've modified in two ways: 1) (Uncontroversial) Removed code to make module work in earlier versions of Python without the unicode() built-in 2) (Poss. controversial) Instead of making string.zfill take the repr() of non-string objects, take the str(). Should a warning be added to this branch of the code so that the automatic str() can be deprecated? 2.2.2 bugfix candidate, assuming the repr()->str() change is deemed OK.
* string.split() docstring described the interpretation of the maxsplitFred Drake2002-01-301-3/+3
| | | | | argument incorrectly. This closes SF bug #505997.
* Added the constants ascii_letters, ascii_lowercase, and ascii_uppercaseFred Drake2001-07-201-0/+3
| | | | | to the string module. This was determined to be the right approach in SF bug #226706.
* removed __all__ from several modulesSkip Montanaro2001-02-181-6/+0
|
* bunch more __all__ listsSkip Montanaro2001-02-151-0/+6
| | | | | | also modified check_all function to suppress all warnings since they aren't relevant to what this test is doing (allows quiet checking of regsub, for instance)
* Nuke accurate but confusing and unhelpful comments about split vs splitfields.Tim Peters2001-02-091-1/+0
|
* String method conversion.Eric S. Raymond2001-02-091-1/+1
|
* Whitespace normalization.Tim Peters2001-01-151-1/+1
|
* Make string.translate(s, table) work for Unicode s. Two things areGuido van Rossum2000-12-191-4/+11
| | | | | | | | | | | required to work around restrictions on the arguments of u.translate(): 1) don't pass the deletions argument if it's empty; 2) convert table to Unicode if s is Unicode. This fixes SF bug #124060.
* Fix serious typo!Fred Drake2000-09-181-1/+3
| | | | Add the new constants to the module docstring.
* Richard Mortier <rmm1002@users.sourceforge.net>:Fred Drake2000-09-181-0/+2
| | | | Add the constants "printable" and "punctuation" to the string module.