Dumb Stupid Question About List and String

Xavier Ho contact at xavierho.com
Wed Sep 1 19:18:13 CEST 2010

On 2 September 2010 02:49, Alban Nona <python.koda at gmail.com> wrote:

> Well what Iam trying to generate is that kind of result:
> listn1=['ELM001_DIF', 'ELM001_SPC', 'ELM001_RFL', 'ELM001_SSS',
> 'ELM001_REFR', 'ELM001_ALB', 'ELM001_AMB', 'ELM001_NRM', 'ELM001_MVE',
> 'ELM001_DPF', 'ELM001_SDW', 'ELM001_MAT', 'ELM001_WPP']
> listn2 = ['ELM002_DIF', 'ELM002_SPC', 'ELM002_RFL', 'ELM002_SSS',
> 'ELM002_REFR', 'ELM002_ALB', 'ELM002_AMB', 'ELM002_NRM', 'ELM002_MVE',
> 'ELM002_DPF', 'ELM002_SDW', 'ELM002_MAT', 'ELM002_WPP']
> etc...

Have a look at http://www.ideone.com/zlBeB .
I took some liberty and renamed some of your variables. I wanted to show you
what I (personally) think as good practices in python, from naming
conventions to how to use the list and dictionary, and so on. Also, 4-spaces
indent. I noticed you have 5 for some reason, but that's none of my business
now. I hope my comments explain what they do, and why they are that way.

> The thing is, the first list will be generated automatically. (so there
> will be unknow versions of ELM00x....)
> that why Im trying to figure out how to genere variable and list in an
> automatic way.

Yes, that's totally possible. See range() (and xrange(), possibly) in the
Python API.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100902/7d5b3bda/attachment.html>

More information about the Python-list mailing list