read() file??
Erik Max Francis
max at alcyone.com
Tue Sep 10 16:13:44 EDT 2002
jubafre at brturbo.com wrote:
> I have a file with assembler instruction and i want read the
> lines of the file and put in a list of string, this is easy to do, but
> i don´t want to consider the caracteres "/" and the othes after him.
>
> file.asm:
> ADD D1 /coment1
> LDA D2 /coment2
>
> list of strings:
> X=[ 'ADD D1' , 'LDA D2' ]
Do something like (unested):
result = []
for line in readlines:
if line[-1] == '\n':
line = line[-1]
if line.find('/') >= 0:
line = line.split('/', 1)[0]
line = line.strip()
result.append(line)
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ I sidestep the either
\__/ or choices of logic and choose both. | Ken Feit
PyUID / http://www.alcyone.com/pyos/uid/
A module for generating "unique" IDs in Python.
More information about the Python-list
mailing list