help

Joel Goldstick joel.goldstick at gmail.com
Wed Jan 30 17:09:49 EST 2013


On Wed, Jan 30, 2013 at 4:16 PM, <aramildaern at gmail.com> wrote:

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

No intrusion.  That is what the list is for.

Two points:

You should use a descriptive subject line -- "Help" isn't really
descriptive.
You should run your code, cut and paste the traceback you get showing the
errors.  This is extremely useful for people to help you with, and as you
program, you will learn how useful it can be to find problems on your own.

So, do that, and come back with that info

>
> 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!
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130130/8eadff7d/attachment.html>


More information about the Python-list mailing list