[Tutor] OK here goes nothing [list manipulation]
Wesley Chun
wesc@deirdre.org
Mon, 14 Jan 2002 21:04:43 -0800 (PST)
On Mon, 14 Jan 2002, Danny Yoo wrote:
>
> > print "-----------------------------------------------------"
>
> There's an easier way to do this:
>
> print '-' * 60
everyone has such great ideas. i thought i would just elaborate
a little on danny's suggestion, which is an oldie but goodie!!
if this print statement is inside a loop, the Python virtual
machine (VM) has to execute 60 string concatenations each time,
which may (or may not) affect performance. a better way to do
it would be to perform this calculation once, and use that
instead for every future occurrence:
dashes =3D '-' * 60=09=09# do it once
:
print dashes=09=09=09# use whenever
:
some_loop:
:
print dashes=09=09# esp. in loops!
hope this helps!!
-wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall PTR, =A9 2001
http://starship.python.net/crew/wesc/cpp/
wesley.j.chun :: wesc@deirdre.org
cyberweb.consulting : henderson, nv : cyberweb@rocketmail.com
http://www.roadkill.com/~wesc/cyberweb/