Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37979

Re: help

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'argument': 0.04; 'error:': 0.05; 'sys': 0.05; 'cure': 0.07; 'everyone!': 0.07; 'filename': 0.07; 'parameter': 0.07; 'skip:/ 10': 0.07; 'terminated': 0.07; 'subject:help': 0.07; 'python': 0.09; 'filename,': 0.09; 'filename.': 0.09; 'ioerror:': 0.09; 'def': 0.10; "'r')": 0.16; '-1:': 0.16; '20)': 0.16; '33,': 0.16; 'advance!': 0.16; 'attached,': 0.16; 'describing': 0.16; 'files")': 0.16; 'for,': 0.16; 'summarize': 0.16; 'string': 0.17; 'wrote:': 0.17; 'compilation': 0.17; 'input': 0.18; 'code.': 0.20; 'import': 0.21; 'do.': 0.21; 'supposed': 0.21; 'errors': 0.23; 'command': 0.24; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'label': 0.27; "doesn't": 0.28; 'fixed': 0.28; 'worked': 0.30; 'error': 0.30; 'file': 0.32; 'message.': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'skip:d 20': 0.34; 'version': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'but': 0.36; 'anything': 0.36; 'skip:p 20': 0.36; 'display': 0.36; 'being': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'mean': 0.38; 'skip:l 20': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'your': 0.60; 'first': 0.61; 'email addr:gmail.com': 0.63; 'show': 0.63; 'great': 0.64; 'received:74.208': 0.71; 'dict()': 0.84; 'directory:': 0.84; 'open,': 0.84
Date Wed, 30 Jan 2013 22:13:54 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: help
References <cf3b0f42-a133-45df-b1c8-8291b1896878@googlegroups.com>
In-Reply-To <cf3b0f42-a133-45df-b1c8-8291b1896878@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:g/zb1DyemPGw5mUXDoLvD4G/GMYmnP3MCPCd+qscHYP k9h75IHiEOn4/zqaWTiAieUkSZ9hIfvtuLSJt+XWKo6liA1yVK IJBU4o/OZZQoVO71c3XHqAlnxdeGx1+gnAldAxoZ7Qr8cKNMW/ W/y8cd1G1+Uf1mq5x+LHDehoEcs/EZGd12/672JWCIUQ3y0bkA uUVMDCYht9cTMOV8K71ApWuJBiW1rsHZlqRUrSAGscoW/rYMh6 pIVr9hsEWOubrojMebdS4JLsaomaLtbCmQAL9QG5WBzqwzh31x CHq0rgvHnuFFlHx8cGbKPKEGZLbdplXfSUcsPtAjLVlJvTH4A= =
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1241.1359602057.2939.python-list@python.org> (permalink)
Lines 92
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1359602057 news.xs4all.nl 6866 [2001:888:2000:d::a6]:41127
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37979

Show key headers only | View raw


On 01/30/2013 04:16 PM, aramildaern@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.
>
> 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!
>

davea@think2:~/temppython$ python aram.py
error: no input files
compilation terminated


These messages are triggered by sys.argv being less than 2.  Cure is to 
pass some string as the first argument on the command line.

Fixed that:

davea@think2:~/temppython$ ./aram.py  myfile.txt
Traceback (most recent call last):
   File "./aram.py", line 33, in <module>
     jadeFile = open(fileName, 'r')
IOError: [Errno 2] No such file or directory: 'myfile.txt'

(notice that I pasted the full traceback into this message.)
Problem is that the program is treating that parameter as a filename, 
and I don't have a file by that filename.

davea@think2:~/temppython$ ./aram.py  aram.py
) != -1:
)
('                stripLabel = line.find("::label")', ':', 20)
('!= -1:', ':', 19)

Worked perfectly.  Of course, nobody has said what it's supposed to do. 
  So anything that doesn't display an error must be okay.

How about describing what version of Python this is intended for, how 
you ran it, and what errors you're getting.  Don't paraphrase, don't 
summarize (lots of errors ???!), just copy/paste.

And if it's appropriate, show a sample data file for it to open, not 
attached, but pasted into your email message.

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

help aramildaern@gmail.com - 2013-01-30 13:16 -0800
  Re: help Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-30 15:08 -0700
  Re: help Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-30 17:09 -0500
  Re: help Chris Angelico <rosuav@gmail.com> - 2013-01-31 09:20 +1100
  Re: help Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-31 13:42 +1100
  Re: help Dave Angel <d@davea.name> - 2013-01-30 22:13 -0500

csiph-web