Commit Graph

130 Commits

Author SHA1 Message Date
Fred Drake 282be3ab89 - explain the start argument to sum()
- various adjustments to sum() markup and explanation
2003-04-22 14:52:08 +00:00
Alex Martelli a70b19147f Adding new built-in function sum, with docs and tests. 2003-04-22 08:12:33 +00:00
Walter Dörwald 2e0b18af30 Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative
positions are treated as being relative to the end of
the input and out of bounds positions result in an
IndexError.

Also update the PEP and include an explanation of
this in the documentation for codecs.register_error.

Fixes a small bug in iconv_codecs: if the position
from the callback is negative *add* it to the size
instead of substracting it.

From SF patch #677429.
2003-01-31 17:19:08 +00:00
Raymond Hettinger 69bf8f3f4e SF bug #655271: Slightly modify locals() doc
Clarify the operation of locals().
2003-01-04 02:16:22 +00:00
Fred Drake 45e482fd3d Document that apply() is deprecated. See:
http://mail.python.org/pipermail/python-dev/2003-January/031556.html
2003-01-02 04:54:04 +00:00
Neal Norwitz 046b8a7244 Fix SF # 641111, Undocumented side effect of eval
Try to clear up confusion about the current globals being copied
into a globals dict passed to eval().  This wording (more or less)
was suggested in bug report.  It should probably be made clearer.

Backport candidate.
2002-12-17 01:08:06 +00:00
Neal Norwitz e9ce25e512 Fix SF #642742, property() builtin not documented
Added doc for functions new to 2.2:  classmethod property staticmethod super
Taken from docstrings.  Could use review.
Hope there wasn't a reason why these shouldn't have been added.

Backport candidate.
2002-12-17 01:02:57 +00:00
Walter Dörwald d9a6ad3beb Enhance issubclass() and PyObject_IsSubclass() so that a tuple is
supported as the second argument. This has the same meaning as
for isinstance(), i.e. issubclass(X, (A, B)) is equivalent
to issubclass(X, A) or issubclass(X, B). Compared to isinstance(),
this patch does not search the tuple recursively for classes, i.e.
any entry in the tuple that is not a class, will result in a
TypeError.

This closes SF patch #649608.
2002-12-12 16:41:44 +00:00
Fred Drake 6e596b6895 Added change note about returning a dictionary based on keyword
arguments.
2002-11-23 15:02:13 +00:00
Just van Rossum a797d8150d Patch #642500 with slight modifications: allow keyword arguments in
dict() constructor. Example:
  >>> dict(a=1, b=2)
  {'a': 1, 'b': 2}
  >>>
2002-11-23 09:45:04 +00:00
Walter Dörwald f171540ab8 Change int() so that passing a string, unicode, float or long argument
that is outside the integer range no longer raises OverflowError, but
returns a long object instead.

This fixes SF bug http://www.python.org/sf/635115
2002-11-19 20:49:15 +00:00
Fred Drake 9482d2591a Update example for the type() function to use the currently accepted
preference of using "is" instead of "==" to compare types, use
built-in names where available, and point to the isinstance()
function.
Closes SF bug #632196.
2002-11-01 21:33:44 +00:00
Fred Drake d6cf8bea0a Modify example to use string methods instead of the string module. 2002-10-22 20:31:22 +00:00
Fred Drake 3e930ba55f Another try at clarifying what goes into and comes out of Unicode objects. 2002-09-24 21:08:37 +00:00
Fred Drake 7b788e0582 Clarify that len() of a Unicode string returns the number of storage units,
not abstract characters.
2002-09-24 13:57:21 +00:00
Raymond Hettinger d918884bb8 Fix typo 2002-09-04 23:52:42 +00:00
Fred Drake 5ec486b87a Add a note that apply() is needed since the extended call syntax is
completely equivalent.
2002-08-22 14:27:35 +00:00
Guido van Rossum 45ec02aed1 SF patch 576101, by Oren Tirosh: alternative implementation of
interning.  I modified Oren's patch significantly, but the basic idea
and most of the implementation is unchanged.  Interned strings created
with PyString_InternInPlace() are now mortal, and you must keep a
reference to the resulting string around; use the new function
PyString_InternImmortal() to create immortal interned strings.
2002-08-19 21:43:18 +00:00
Fred Drake 2095b9690f reduce(): Clarified what is returned in the case of a sequence 1 item long and
initial/default value.
2002-07-17 13:55:33 +00:00
Fred Drake 4254cbd29c Note that unicode() can raise LookupError for unknown codecs.
Closes SF bug #513666.
2002-07-09 05:25:46 +00:00
Fred Drake 50e1286c00 Fix typo: "an Unicode string" --> "a Unicode string"
Clarify the return value when the parameter is a Unicode object.
2002-07-08 14:29:05 +00:00
Fred Drake 78e057a32a Clarify the version information for the unicode() built-in.
Closes SF bug #575272.
2002-06-29 16:06:47 +00:00
Fred Drake 807354f3b6 Add a note that divmod() with complex numbers is deprecated. 2002-06-20 21:10:25 +00:00
Barry Warsaw 177b4a065f Jack's documentation for the U mode character on the file()
constructor, vetted by Barry.
2002-05-22 20:39:43 +00:00
Raymond Hettinger 6cf09f0792 Patch 543387. Document deprecation of complex %, //,and divmod(). 2002-05-21 18:19:49 +00:00
Fred Drake 38f71973e5 Documentation for the enumerate() function/type.
This closes SF patch #547162.
2002-04-26 20:29:44 +00:00
Fred Drake 933f159a2f Add a version annotation for the help() function. 2002-04-17 12:54:04 +00:00
Guido van Rossum 77f6a65eb0 Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
2002-04-03 22:41:51 +00:00
Fred Drake da8a6dd072 Added missing version annotation for dict(). 2002-03-06 02:29:30 +00:00
Tim Peters 9f4341b3b0 SF bug #501591: dir() doc is old
Bugfix candidate.

+ Updated dir() description to match actual 2.2 behavior.

+ Replaced the dir(sys) example with dir(struct), because the former
  was way out of date and is bound to change frequently, while the
  latter is stable.

+ Added a note cautioning that dir() is supplied primarily for
  convenience at an interactive prompt (hoping to discourage its
  use as the foundation of introspective code outside the core).
2002-02-23 04:40:15 +00:00
Fred Drake 732299ff63 Add documentation for the help() built-in; contributed by Ka-Ping Yee.
This is part of SF patch #494622.
2001-12-18 16:31:08 +00:00
Fred Drake 526c7a0101 Ensure that complex() only accepts a string argument as the first arg,
and only if there is no second arg.
This closes SF patch #479551.
2001-12-13 19:52:22 +00:00
Fred Drake 5172adca81 Minor clarification of the zip() description, based on a comment sent to
python-docs.
2001-12-03 18:35:05 +00:00
Fred Drake 3570551d6f Remove most references to __members__ and __methods__, leaving only one pair
of references that now state that these attributes have been removed,
directing the reader to the dir() function.
This closes SF bug #456420.
2001-12-03 17:32:27 +00:00
Fred Drake 0b66310476 When referring to a formal parameter from the description, use the name given
with the signature, not an ad hoc abbreviated form.
2001-11-07 06:28:47 +00:00
Fred Drake 66ded524ba apply() documentation: Remove a detail about the implementation that does
not affect the API.  Clean up the text about call syntax apply() is
equivalent to.  Based on comments by Thomas Guettler.
2001-11-07 06:22:25 +00:00
Tim Peters a427a2b8d0 Rename "dictionary" (type and constructor) to "dict". 2001-10-29 22:25:45 +00:00
Fred Drake ef7d08a661 Some style changes and typo fixes. 2001-10-26 15:04:33 +00:00
Tim Peters 1fc240e851 Generalize dictionary() to accept a sequence of 2-sequences. At the
outer level, the iterator protocol is used for memory-efficiency (the
outer sequence may be very large if fully materialized); at the inner
level, PySequence_Fast() is used for time-efficiency (these should
always be sequences of length 2).

dictobject.c, new functions PyDict_{Merge,Update}FromSeq2.  These are
wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2-
sequences argument instead of a mapping object.  For now, I left these
functions file static, so no corresponding doc changes.  It's tempting
to change dict.update() to allow a sequence-of-2-seqs argument too.

Also changed the name of dictionary's keyword argument from "mapping"
to "x".  Got a better name?  "mapping_or_sequence_of_pairs" isn't
attractive, although more so than "mosop" <wink>.

abstract.h, abstract.tex:  Added new PySequence_Fast_GET_SIZE function,
much faster than going thru the all-purpose PySequence_Size.

libfuncs.tex:
- Document dictionary().
- Fiddle tuple() and list() to admit that their argument is optional.
- The long-winded repetitions of "a sequence, a container that supports
  iteration, or an iterator object" is getting to be a PITA.  Many
  months ago I suggested factoring this out into "iterable object",
  where the definition of that could include being explicit about
  generators too (as is, I'm not sure a reader outside of PythonLabs
  could guess that "an iterator object" includes a generator call).
- Please check my curly braces -- I'm going blind <0.9 wink>.

abstract.c, PySequence_Tuple():  When PyObject_GetIter() fails, leave
its error msg alone now (the msg it produces has improved since
PySequence_Tuple was generalized to accept iterable objects, and
PySequence_Tuple was also stomping on the msg in cases it shouldn't
have even before PyObject_GetIter grew a better msg).
2001-10-26 05:06:50 +00:00
Marc-André Lemburg b5507ecd3c Additional test and documentation for the unicode() changes.
This patch should also be applied to the 2.2b1 trunk.
2001-10-19 12:02:29 +00:00
Fred Drake e0063d20a7 Update the documentation for the isinstance() function to reflect recent
changes in the implementation.
Indented all descriptions consistently.
2001-10-09 19:31:08 +00:00
Tim Peters 3899d74c10 Make clear that tuple() accepts the same kind of arguments as list(). 2001-10-04 06:53:20 +00:00
Tim Peters af5910f025 The execfile() docs imply it acts on locals same as exec. But in truth
it acts more like assigning to keys in locals(), i.e. modifications to
function locals aren't reflected in the locals when execfile() returns.
2001-09-30 06:32:59 +00:00
Tim Peters 1c33daf143 Correct docs for long(float). 2001-09-30 06:18:26 +00:00
Guido van Rossum 0d68246f01 Fix two typos in the text about compile(), and add two caveats from
recent user feedback: you must end the input with \n and you must use
\n, not \r\n to represent line endings.
2001-09-29 14:28:52 +00:00
Tim Peters 2e29bfbe1a Document new file() constructor, with the body of open()'s text, plus a
"new in 2.2" blurb at the end.  Replace open()'s text by pointing back
to file().
2001-09-20 19:55:29 +00:00
Fred Drake 00bb329521 Document the built-in iter() function. 2001-09-06 19:04:29 +00:00
Tim Peters 32f453eaa4 New restriction on pow(x, y, z): If z is not None, x and y must be of
integer types, and y must be >= 0.  See discussion at
http://sf.net/tracker/index.php?func=detail&aid=457066&group_id=5470&atid=105470
2001-09-03 08:35:41 +00:00
Michael W. Hudson 53da317801 Docs for the PEP 264 changes. 2001-08-27 20:02:17 +00:00
Tim Peters 7321ec437b SF bug #444510: int() should guarantee truncation.
It's guaranteed now, assuming the platform modf() works correctly.
2001-07-26 20:02:17 +00:00