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


Groups > comp.lang.python > #109192

Re: How can I debug silent failure - print no output

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From cs@zip.com.au
Newsgroups comp.lang.python
Subject Re: How can I debug silent failure - print no output
Date Sat, 28 May 2016 14:35:18 +1000
Lines 52
Message-ID <mailman.5.1464411749.1839.python-list@python.org> (permalink)
References <c2be905c-528d-4384-a127-d2ee8ea41f13@googlegroups.com> <20160528043518.GA84172@cskk.homeip.net>
Reply-To python-list@python.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
X-Trace news.uni-berlin.de PSW93mSV+zj03JRU1ldlfwRtMX4blFWwtveXaxV6oY6Q==
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'args': 0.04; 'python3': 0.05; 'calls.': 0.07; 'sanity': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'filenames,': 0.09; 'happen.': 0.09; 'files.': 0.13; '"*"': 0.16; '2016': 0.16; '>on': 0.16; 'empty.': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'iterating': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'path).': 0.16; 'received:172.16.3': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'set()': 0.16; 'set,': 0.16; 'simpson': 0.16; 'subject:debug': 0.16; 'wrote:': 0.16; 'debugging': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'extension': 0.20; 'parser': 0.22; 'cheers,': 0.22; 'cc:no real name:2**0': 0.22; 'xml': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'command': 0.26; 'earlier': 0.27; 'points': 0.27; 'skip:f 40': 0.27; 'function': 0.28; "skip:' 10": 0.28; 'actual': 0.28; 'program,': 0.29; "i'd": 0.31; 'error.': 0.31; 'probably': 0.31; 'michael': 0.33; 'add': 0.34; 'list': 0.34; 'filter': 0.35; 'path': 0.35; 'returning': 0.35; 'skip:> 10': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'charset:us-ascii': 0.37; 'things': 0.38; 'doing': 0.38; 'skip:p 20': 0.38; 'files': 0.38; 'means': 0.39; 'sure': 0.39; 'from:no real name:2**0': 0.60; 'your': 0.60; 'skip:n 10': 0.62; 'saturday,': 0.63; 'more': 0.63; 'cameron': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'received:61': 0.72; '>def': 0.84; 'expect.': 0.84; 'learn.': 0.84; 'reply-to:addr:python.org': 0.84; 'thing,': 0.93
X-Authentication-Info Submitted using ID cskk@bigpond.com
X-Authority-Analysis v=2.1 cv=A52RRPiG c=1 sm=1 tr=0 a=9mnmWbg0aQouTwjTD+C4gg==:117 a=9mnmWbg0aQouTwjTD+C4gg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=yrkiwgmsf1kA:10 a=pGLkceISAAAA:8 a=vrnE16BAAAAA:8 a=EB062LGQjLCrRis05dAA:9 a=CjuIK1q_8ugA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 a=D4O83h6meWPcCEhhlUO6:22
Content-Disposition inline
In-Reply-To <c2be905c-528d-4384-a127-d2ee8ea41f13@googlegroups.com>
User-Agent Mutt/1.5.24 (2015-08-30)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <20160528043518.GA84172@cskk.homeip.net>
X-Mailman-Original-References <c2be905c-528d-4384-a127-d2ee8ea41f13@googlegroups.com>
Xref csiph.com comp.lang.python:109192

Show key headers only | View raw


On 27May2016 21:02, Sayth Renshaw <flebber.crue@gmail.com> wrote:
>On Saturday, 28 May 2016 13:06:59 UTC+10, Michael Torrie  wrote:
>> Add more print() calls. Offhand I'd say that pq(filename=filename) is
>> returning an empty list so that for loop is not doing anything.  Hence
>> your debugging print() calls never happen.
>>
>> Add sanity print()'s earlier in your program, and make sure everything
>> you are iterating over is what you expect.
>
>Ok after printing a few things i have found an error.
>
>def GetArgs():
>    '''parse XML from command line'''
>    parser = argparse.ArgumentParser()
>
>    parser.add_argument("path", nargs="+")
>    parser.add_argument('-e', '--extension', default='',
>                        help='File extension to filter by.')
>    args = parser.parse_args()
>
>    files = set()
>    name_pattern = "*" + args.extension
>    for path in args.path:
>        files.update(glob.glob(os.path.join(path, name_pattern)))
>
>    print(files)
>    return files
>
>a = GetArgs()
>print(a)
>
>so printing the files or the call to the function returns set() not the actual files.

Since you're constructing a set of filenames, this means it is probably 
returning the right kind of thing, but it is empty. That points to the glob not 
doing what you want or the for-loop not doing anything.

>[sayth@localhost pyXML]$ python3 racemeeting.py data/*.xml
>set()
>set()
>set()

So...  Add more prints!

Specificly, print(args) right after it is set, and put a print() _inside_ the 
loop before the call to files.update, probably printing "path", eg print("path 
=", path).

Then see what you learn.

Cheers,
Cameron Simpson <cs@zip.com.au>

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


Thread

How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-27 19:41 -0700
  Re: How can I debug silent failure - print no output Michael Torrie <torriem@gmail.com> - 2016-05-27 21:06 -0600
    Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-27 21:02 -0700
      Re: How can I debug silent failure - print no output cs@zip.com.au - 2016-05-28 14:35 +1000
        Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-27 23:35 -0700
          Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-28 00:14 -0700
            Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-28 01:01 -0700
              Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-28 02:44 -0700
                Re: How can I debug silent failure - print no output Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-28 03:32 -0700
                Re: How can I debug silent failure - print no output cs@zip.com.au - 2016-05-29 08:43 +1000
          Re: How can I debug silent failure - print no output Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-05-28 12:52 -0400
  Re: How can I debug silent failure - print no output Jason Friedman <jsf80238@gmail.com> - 2016-05-27 22:02 -0600

csiph-web