"join" operates on lists. It "joins" the elements of the list using the
leading character or string as the delimiter. In this case it is NUL.
Try putting a character or string, like 'XX\n' in front of the ".join" in
both places. It should illustrate what's really happening.
"XX\n".join(...)
In the original case, "join" is presented with a list.
In the second case, "join" is presented with a string. But Python happily
converts it to a list of characters.
----- Original Message -----
From: "Roelof Wobben" <rwob...@hotmail.com>
To: <tutor@python.org>
Sent: Thursday, October 14, 2010 6:50 AM
Subject: [Tutor] join question
Hello,
I found this answer to a problem for me :
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
print ''.join(test)
But it seems not to work
Can anyone explain why not ?
Roelof
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor