Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'parameters': 0.04; 'source,': 0.04; 'subject:code': 0.07; 'subject:help': 0.08; 'calls.': 0.09; 'indication': 0.09; 'key.': 0.09; 'specific.': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; "(i'm": 0.16; 'file"': 0.16; 'filters,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'grep': 0.16; 'incorrect': 0.16; 'likewise': 0.16; 'open()': 0.16; 'overriding': 0.16; 'path.': 0.16; 'roy': 0.16; 'skip:~ 20': 0.16; 'subject:when': 0.16; 'symlink': 0.16; 'usage,': 0.16; 'wanted.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; 'cc:addr:python.org': 0.22; 'config': 0.24; 'filtering': 0.24; 'own.': 0.24; 'tend': 0.24; 'fairly': 0.24; 'mon,': 0.24; 'looks': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'somewhere': 0.26; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; 'helpful.': 0.31; 'libraries': 0.31; 'trace': 0.31; 'trivial': 0.31; 'file': 0.32; 'figure': 0.32; 'run': 0.32; 'another': 0.32; 'there,': 0.34; 'could': 0.34; 'common': 0.35; 'tool': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'tight': 0.36; 'done': 0.36; "didn't": 0.36; "i'll": 0.36; 'too': 0.37; 'sometimes': 0.38; 'filter': 0.38; 'tools,': 0.38; 'needed': 0.38; 'files': 0.38; 'pm,': 0.38; 'rather': 0.38; "couldn't": 0.39; 'though,': 0.39; 'sure': 0.39; 'unable': 0.39; 'even': 0.60; 'liked': 0.60; 'most': 0.60; 'simple': 0.61; 'save': 0.62; 'times': 0.62; 'reach': 0.63; 'fire': 0.65; 'line,': 0.68; 'smith': 0.68; 'jul': 0.74; 'repeat': 0.74; 'subject:your': 0.76; 'article': 0.77; 'filtered': 0.84; 'game,': 0.84; 'local,': 0.84; 'much,': 0.84; 'rinse': 0.84; 'subject:you': 0.87; 'watched': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=SL5LA0MKtCtL3j5+llx/9MM9b2WNlW2ajo7HjDCrsAE=; b=eNpfgBleyDms5kLYJCLoNzN7DPtl49FdGo4yeG+EofrVuG5Wr9JV932cJ2XWzUUyL7 kp9asUJIk/11H+fS4k01sXV1gmJxUku6vRVCitv1o8enLCjylpCA649HwAhffq3z4QON vvGnaWg18lBg4995Km7aInGsqHIVYU6D4g84isBcKaF6YmrCAmSyz0o3vv465s3YFssU zlj/F8t+loy5uti3gFGymd9W+RG//tf4XfJRXblriOvkdmkAzMJTdI2KKfKYtKi/6j2p 1TUy9umGCjGEg47MVtMj4Nvq1vdPMoeGUAFMPOZBr1585+hQKd5MQHsA9ukgDVxfrdes yLdg== MIME-Version: 1.0 X-Received: by 10.52.231.226 with SMTP id tj2mr9741538vdc.16.1404732975888; Mon, 07 Jul 2014 04:36:15 -0700 (PDT) In-Reply-To: References: Date: Mon, 7 Jul 2014 21:36:15 +1000 Subject: Re: How do you use `help` when write your code From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404732978 news.xs4all.nl 2901 [2001:888:2000:d::a6]:37316 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74095 On Mon, Jul 7, 2014 at 9:22 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> That's about it, yeah. I tend to find both strace and tcpdump rather >> too spammy for most usage, so any time I reach for those tools, it's >> usually with some tight filtering - and even that's not always >> helpful. > > Usually, when I fire up strace, it's because I'm looking for something > specific. A common use case is, "I just edited this config file, but it > doesn't seem to be having any effect". I'll do something like "strace > -e file" and grep out all the open() calls. From there, it's trivial to > verify that it is indeed reading my config file (or not). Or that > there's other config files (/usr/share/whatever) that it's reading that > I didn't even know existed, which might be overriding my own. Likewise > for which libraries it's linking against, which executables it's > running, etc. Yep. Sometimes it's fairly easy. I was trying to figure out where rdesktop was looking for its keymaps, and rather than hunt down the source, I just straced it and watched for errors, and found that it was looking for ~/.rdesktop/keymaps, so I made that as a symlink to what I wanted. (I'm sure I could have found this somewhere in the docs, but after a small amount of searching, I didn't have any indication of where; and for this job, I needed it to be local, rather than in a root-owned directory.) That one was pretty straight-forward. The time I was trying to trace that game, though, I was trying to figure out why it was unable to save screenshots; and since the most likely cause was an incorrect path name, I couldn't search for the path. Had to negate the search - run the trace, then filter out everything that looks like the one most common line, rinse and repeat until it's silent. Then hit the screenshot key. Whoops, filtered out too much, didn't see a thing.... weaken the filters, start again. Would have liked source code for THAT one! A simple line of "write my parameters to stderr" would have done the job. At the end of the day, it's just another tool in the box. You learn to use it because there are times when it's the right one for the job. ChrisA