[Tutor] Different idioms for making lists of strings

Magnus Lycka magnus@thinkware.se
Fri, 06 Sep 2002 12:53:27 +0200


At 16:50 2002-09-05 -0700, Sean 'Shaleh' Perry wrote:
>On Thursday 05 September 2002 16:35, Scot W. Stevenson wrote:
> > alist =3D 'From To Subject'.split()
>
>My only problem with this is it masks the intent of the code.

Your second problem will occur the day you realize that you
need a space in one of the strings in your list...

I don't think this is in general a good idea, but something
along those lines might be useful in some occations. Like this:
(For Steve Lewis who just wanted a gentle hint...sorry ;)

programs =3D '''
# Std Windows stuff
notepad.exe
winword.exe
excel.exe

# To make it feel more like Unix
g:/cygwin/bin/bash.exe
'''

import os
for program in programs.split('\n'):
     if program and program[0] !=3D '#':
         os.system('start %s' % program)

Writing the script like that will probably make it
easier for a non-programmer to maintain the list of
programs.


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se