From 758d92b33e4000cd2555b6a174a60f029ef60c84 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 16 Jan 2006 20:36:42 +0000 Subject: [PATCH] seq.attr("__len__")() replaced by len(seq); obsolete len() example removed [SVN r32337] --- doc/v2/object.html | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/doc/v2/object.html b/doc/v2/object.html index 40798e8e..ed4538af 100644 --- a/doc/v2/object.html +++ b/doc/v2/object.html @@ -905,7 +905,16 @@ template<class R> object& operator|=(object&l,R const&r);
Returns: l.
-

Example

+
+inline long len(object const& obj);
+
+ +
+
Effects: PyObject_Length(obj.ptr())
+
Returns: len() of object.
+
+ +

Example

Python code:
 def sum_items(seq):
@@ -919,35 +928,14 @@ def sum_items(seq):
 object sum_items(object seq)
 {
    object result = object(0);
-   for (int i = 0; i < seq.attr("__len__")(); ++i)
+   for (int i = 0; i < len(seq); ++i)
       result += seq[i];
    return result;
 }
 
- -

len()

-
-inline long len(object const& obj);
-
- -
-
Effects: PyObject_Length(obj.ptr())
-
Returns: len() of object.
-
- -

Example

- Python code: -
-len(obj)
-
- C++ version: -
-len(obj);
-
-

Revised - 12 January, 2006 + 13 January, 2006

@@ -955,4 +943,3 @@ len(obj); "../../../../people/dave_abrahams.htm">Dave Abrahams 2006.

-