[Tutor] join question

davidheiserca at gmail.com davidheiserca at gmail.com
Thu Oct 14 17:28:49 CEST 2010

"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.


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" <rwobben at hotmail.com>
To: <tutor at 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 at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor 

More information about the Tutor mailing list