[pypy-svn] rev 630 - pypy/trunk/src/pypy/objspace/std
tomek at codespeak.net
tomek at codespeak.net
Wed May 28 17:37:35 CEST 2003
Author: tomek
Date: Wed May 28 17:37:34 2003
New Revision: 630
Modified:
pypy/trunk/src/pypy/objspace/std/stringobject.py
pypy/trunk/src/pypy/objspace/std/stringobject_app.py
Log:
implemented join
Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py Wed May 28 17:37:34 2003
@@ -1,6 +1,9 @@
from pypy.objspace.std.objspace import *
from intobject import W_IntObject
from sliceobject import W_SliceObject
+from instmethobject import W_InstMethObject
+from pypy.interpreter.extmodule import make_builtin_func
+
applicationfile = StdObjSpace.AppFile(__name__)
@@ -16,6 +19,26 @@
def hash(w_self):
return W_IntObject(self, hash(self.value))
+ def join(w_self, w_list):
+ firstelem = 1
+ res = ""
+ for w_item in w_list.wrappeditems:
+ if firstelem:
+ res = w_item.value
+ firstelem = 0
+ else:
+ res = res + w_self.value + w_item.value
+
+ return W_StringObject(w_self.space, res)
+
+def getattr_str(space, w_list, w_attr):
+ if space.is_true(space.eq(w_attr, space.wrap('join'))):
+ w_builtinfn = make_builtin_func(space, W_StringObject.join)
+ return W_InstMethObject(space, w_list, w_builtinfn)
+ raise FailedToImplement(space.w_AttributeError)
+
+StdObjSpace.getattr.register(getattr_str, W_StringObject, W_ANY)
+
def str_unwrap(space, w_str):
return w_str.value
Modified: pypy/trunk/src/pypy/objspace/std/stringobject_app.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject_app.py (original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject_app.py Wed May 28 17:37:34 2003
@@ -3,3 +3,4 @@
for i in xrange(*sliceob.indices(len(str))):
r.append(str[i])
return ''.join(r)
+
More information about the Pypy-commit
mailing list