help

aramildaern at gmail.com aramildaern at gmail.com
Wed Jan 30 22:16:51 CET 2013


Hi everyone! I don't mean to intrude, but ive heard great things about this group and ive stumped myself with my python code.

heres my code:
#! /usr/bin/python

import sys

global labelList 
labelList= dict()

global counter
counter = 0

def execute(line):
        if line.find("::print") != -1:
                stripPrint = line.find("::print")
                startPrint = line.find('"', stripPrint)
                stopPrint = line.find('"', startPrint + 1)
                printSection = line[startPrint + 1 : stopPrint]
                print(printSection)

        if line.find("::label") != -1:
                stripLabel = line.find("::label")
                startLabel = line.find(' ', stripLabel)
                stopLabel = line.find('--', startLabel + 1)
                label = line[startLabel + 1 : stopLabel]
                line.strip("\r\n")
                labelList[label] = counter

if len(sys.argv) < 2:
        print("error: no input files")
        print("compilation terminated")

else:
        fileName = sys.argv[1]
        jadeFile = open(fileName, 'r')

        for line in jadeFile:
                counter = counter + 1
                execute(line)

        jadeFile.close()

        i = 0

        while i < len(labelList):
                print(labelList.keys()[i], ":", labelList.values()[i])
                i = i + 1


and its giving me a bunch of errors thanks for the help in advance!



More information about the Python-list mailing list