[New-bugs-announce] [issue4534] problem with str.join

jeff deifik report at bugs.python.org
Thu Dec 4 21:34:22 CET 2008


New submission from jeff deifik <jeff at jeffunit.com>:

I compiled python 3.0 on a cygwin platform.

Here is my modest function:

def List_to_String(lis):
#    return str.join(lis, '')		# This is fast, but seems broke in 3.0
    s = ''				# This is really slow, but works in 3.0
    for l in lis: s = s + l
    return s

Here is my test case:
    def test_List_to_String(self):
        inp = ['f', 'r', 'e', 'd', ' ', 'i', 's']
        out = 'fred is'
        self.assertEqual(jefflib.List_to_String(inp), out)

Here is what happens when I try to run the commented out version (the
one with the join):
ERROR: test_List_to_String (__main__.TestJefflibFunctions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./jefflib_test.py", line 96, in test_List_to_String
    self.assertEqual(jefflib.List_to_String(inp), out)
  File "/cygdrive/c/documents and
settings/deifikj/jeff/scripts/jefflib.py", lin
e 256, in List_to_String
    return str.join(lis)
TypeError: descriptor 'join' requires a 'str' object but received a 'list'


Of course, it worked fine in python 2.6.
I am baffled.

----------
components: None
messages: 76924
nosy: lopgok
severity: normal
status: open
title: problem with str.join
type: crash
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4534>
_______________________________________


More information about the New-bugs-announce mailing list