summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in eitherThomas Wouters2000-07-161-1/+1
| | | | | | | | | | comments, docstrings or error messages. I fixed two minor things in test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't"). There is a minor style issue involved: Guido seems to have preferred English grammar (behaviour, honour) in a couple places. This patch changes that to American, which is the more prominent style in the source. I prefer English myself, so if English is preferred, I'd be happy to supply a patch myself ;)
* Martin von Löwis <martin@loewis.home.cs.tu-berlin.de>:Fred Drake2000-07-031-40/+9
| | | | | | | This patch delegates more string functions to string object methods, uses the varargs delegation syntax, and stops using stringold. Closes SourceForge patch #100712.
* Marc-Andre's third try at this bulk patch seems to work (except thatGuido van Rossum2000-04-051-33/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | his copy of test_contains.py seems to be broken -- the lines he deleted were already absent). Checkin messages: New Unicode support for int(), float(), complex() and long(). - new APIs PyInt_FromUnicode() and PyLong_FromUnicode() - added support for Unicode to PyFloat_FromString() - new encoding API PyUnicode_EncodeDecimal() which converts Unicode to a decimal char* string (used in the above new APIs) - shortcuts for calls like int(<int object>) and float(<float obj>) - tests for all of the above Unicode compares and contains checks: - comparing Unicode and non-string types now works; TypeErrors are masked, all other errors such as ValueError during Unicode coercion are passed through (note that PyUnicode_Compare does not implement the masking -- PyObject_Compare does this) - contains now works for non-string types too; TypeErrors are masked and 0 returned; all other errors are passed through Better testing support for the standard codecs. Misc minor enhancements, such as an alias dbcs for the mbcs codec. Changes: - PyLong_FromString() now applies the same error checks as does PyInt_FromString(): trailing garbage is reported as error and not longer silently ignored. The only characters which may be trailing the digits are 'L' and 'l' -- these are still silently ignored. - string.ato?() now directly interface to int(), long() and float(). The error strings are now a little different, but the type still remains the same. These functions are now ready to get declared obsolete ;-) - PyNumber_Int() now also does a check for embedded NULL chars in the input string; PyNumber_Long() already did this (and still does) Followed by: Looks like I've gone a step too far there... (and test_contains.py seem to have a bug too). I've changed back to reporting all errors in PyUnicode_Contains() and added a few more test cases to test_contains.py (plus corrected the join() NameError).
* Marc-Andre Lemburg: the maxsplit argument for split() and replace()Guido van Rossum2000-03-101-4/+4
| | | | | now defaults to -1, not to 0. Passing an explicit zero doesn't split or replace at all.
* Detabify.Fred Drake2000-02-101-28/+28
| | | | I ran "expand" instead of using Skip's patch, but it's all the same.
* The third and final doc-string sweep by Ka-Ping Yee.Guido van Rossum2000-02-041-7/+5
| | | | | | | | The attached patches update the standard library so that all modules have docstrings beginning with one-line summaries. A new docstring was added to formatter. The docstring for os.py was updated to mention nt, os2, ce in addition to posix, dos, mac.
* split() docstring: Made signature and description for the firstFred Drake1999-11-041-2/+2
| | | | | parameter match. Error pointed out by François Pinard <pinard@iro.umontreal.ca> on c.l.py.
* Mainlining the string_methods branch. See branch revision logBarry Warsaw1999-10-121-430/+275
| | | | messages for specific changes.
* Fix PR#31 -- zfill() mishandles empty string.Guido van Rossum1999-10-111-1/+1
|
* As Tim Peters points out, ``from string import *'' should not set re to None.Guido van Rossum1998-04-201-9/+11
| | | | Also rename safe_env to _safe_env.
* Strip argument to atol and atof to match what strop does better.Guido van Rossum1998-03-301-2/+2
|
* A few lines were indented using spaces instead of tabs -- fix them.Guido van Rossum1998-03-261-4/+5
|
* Minor editing corrections.Guido van Rossum1997-12-291-13/+13
|
* Added doc string, provided by Charles Waldman (with some reformattingGuido van Rossum1997-12-291-0/+223
| | | | and a little editing my me).
* At Barry's suggestion, plug the security leak by using an emptyGuido van Rossum1997-12-101-3/+6
| | | | | | __builtins__ for all calls to eval(). This still allows someone to write string.atof("[1]*1000000") (which Jim Fulton worries about) but effectively disables access to system modules and functions.
* Since this module is used as a fallback in case no built-in modulesGuido van Rossum1997-12-101-3/+7
| | | | | | | | | have been configured, string.atof() should not fail when "import re" fails (usually because pcre is not there). This opens up a tiny security hole: *if* an attacker can make "import re" fail, they can also make string.atof(arbitrary_string) evaluate the arbitrary string. Nothing to keep me awake at night...
* In string.split(), honor maxsplit (if > 0).Guido van Rossum1997-12-011-2/+8
| | | | | | | | In string.splitfields(), ignore maxsplit if <= 0, rather than ignoring maxsplit=0 but effectively treating negative numbers the same as maxsplit=1. Also made the test for maxsplit slightly more efficient (set it to the length of the string when <= 0 so the test for its presence can be omitted from the loop).
* Convert all remaining *simple* cases of regex usage to re usage.Guido van Rossum1997-10-221-3/+6
|
* Add optional 4th argument to count(), matching find() etc.Guido van Rossum1997-10-201-7/+14
| | | | | | Also change all occurrences of "x == None" to "x is None" (not that it matters much, these functions are all reimplemented in strop -- but count() is not).
* Changed my mind on replace().Guido van Rossum1997-04-021-12/+2
| | | | | | It's now replace(str, old, new, maxsplit=0). Note new ordering of parameters (string first); this is more consistent with translate().
* Added new functions replace() and replace1().Guido van Rossum1997-03-251-0/+15
|
* Add optional 4th argument to [r]find and [r]index (end of slice).Guido van Rossum1997-03-141-10/+26
|
* Use correct separator for capwords(s, sep).Guido van Rossum1996-08-261-1/+1
|
* Add optional separator character to capwords(), for completeness.Guido van Rossum1996-08-201-2/+2
|