read() file??

Erno Kuusela erno-news at erno.iki.fi
Wed Sep 11 11:27:48 EDT 2002


In article <mailman.1031684894.10361.python-list at python.org>,
jubafre at brturbo.com writes:

| 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

try something like...

def read_asm(filename):
    out = []
    for line in open(filename).readlines():
        out.append(line.split('/')[0])
    return out

  -- erno



More information about the Python-list mailing list