Python equivalent of "lynx -dump"?

Tim Roberts timr at probo.com
Wed Mar 29 08:45:35 CEST 2000


lewst <lewst at yahoo.com> wrote:
>
>Right now I have a python program that captures the output of a
>webpage and prints it like so:
>
>        lynxcmd = "lynx -dump %s" %url

I hope you do not mind if I ask a Python style question unrelated to your
issue.  That source line contains an idiom I see often in the Python code,
and I do not understand why.  To me, it seems wasteful to use the %
operator where simple string concatenation will do the same job more
quickly.  For example, isn't this just as clear?

	lynxcmd = "lynx -dump " + url

Certainly, in C programming, I would never use printf where a simple strcat
would do, and this seems like an exactly parallel situation.

Now, admittedly, I am still quite new to Python.  I see that construct a
LOT in the Python library and sample code, so if I'm missing some bigger
picture here, I would appreciate a gentle correction.
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list