better way than: myPage += 'more html' , ...

sismex01 at hebmex.com sismex01 at hebmex.com
Wed Jun 25 17:14:24 EDT 2003


> From: Dave Kuhlman [mailto:dkuhlman at rexx.com] 
> Sent: Miércoles, 25 de Junio de 2003 04:08 p.m.
> 
> -----------8<--------------
> import string
> ...
> htmlPage=["<html><header></header><body>"]
> htmlPage.append("more html")
> ....
> htmlPage.append("more html")
> ....
> htmlPage.append("<\body><\html>")
> # Use string.join() instead of ''.join() to add new-lines.
> htmlDoc= string.join(htmlPage, '\n')
> -----------8<--------------
> 
> Funny that string.join() supports the optional second parameter,
> while 'abc'.join() does not.
> 
>   - Dave
>

That's because string.join() is a module function, and in the
other case, ".join()" is a method of the string object "abc",
so in that case, "abc" is the "self" parameter.

And, in the case of string.join()'s optional second parameter,
it's default value is "", an empty string (if I'm not mistaken).

It's the same thing as "".join()

Salutations!

-gustavo

---

Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.





More information about the Python-list mailing list