Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'configure': 0.05; 'output': 0.05; 'true,': 0.05; 'args': 0.07; 'debug': 0.07; 'debugging': 0.07; 'subject:code': 0.07; 'subject:help': 0.08; 'string': 0.09; '"or': 0.09; 'debugging.': 0.09; 'defines': 0.09; 'lawrence': 0.09; 'mess': 0.09; 'msg': 0.09; 'subject:How': 0.10; 'def': 0.12; "wouldn't": 0.14; '"from': 0.16; "'''": 0.16; '*args):': 0.16; '>in': 0.16; '>the': 0.16; 'args:': 0.16; 'bypassing': 0.16; 'entirely.': 0.16; 'formatted': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'roy': 0.16; 'simpson': 0.16; 'subject:when': 0.16; 'sys.stderr': 0.16; 'tool.': 0.16; 'x()': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'saying': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; '"you': 0.24; 'module,': 0.24; 'cheers,': 0.24; 'environment': 0.24; "i've": 0.25; 'logging': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'asked': 0.31; '(perhaps': 0.31; 'fighting': 0.31; 'another': 0.32; 'running': 0.33; 'entirely': 0.33; 'programmers': 0.33; 'problem': 0.35; "can't": 0.35; 'but': 0.35; 'received:com.au': 0.36; 'done': 0.36; 'charset:us-ascii': 0.36; 'application': 0.37; 'turn': 0.37; 'two': 0.37; 'configured': 0.38; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'around.': 0.60; 'tell': 0.60; "you're": 0.61; 'times': 0.62; 'content-disposition:inline': 0.62; 'real': 0.63; '21st': 0.68; 'smith': 0.68; 'subject:your': 0.76; 'article': 0.77; '(standard': 0.84; 'alice.': 0.84; 'century': 0.84; 'disappears': 0.84; 'top.': 0.84; 'subject:you': 0.87; '"how': 0.91; 'here."': 0.91 Date: Mon, 7 Jul 2014 11:51:45 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: How do you use `help` when write your code MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=eojmkOZX c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=kJHo6pL0YScA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=HDWgMBI4gAMA:10 a=VUfPOBp7AAAA:8 a=8AHkEIZyAAAA:8 a=BrDiTsk0AAAA:8 a=OakY_Z6gi8YU5oVSQhgA:9 a=CjuIK1q_8ugA:10 a=5hK03km2n30A:10 a=VhVvL8HfBcoA:10 a=-hJg1tCh9CgA:10 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404699666 news.xs4all.nl 2839 [2001:888:2000:d::a6]:41205 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74068 On 06Jul2014 15:15, Roy Smith wrote: >In article , > Mark Lawrence wrote: >> In the 21st century real programmers are using the logging module so >> they don't have to mess around. > >The problem with the logging module is you can configure it to do pretty >much anything, which is another way of saying if it's not configured >right (perhaps because you're running your application in an environment >it wasn't designed for), your output disappears into the ether. > >I can't tell you how many times I've given up fighting with logging and >just done "open("/tmp/x").write("my debugging message\n") when all else >failed. Indeed. I have a cs.logutils module, which is almost entirely support for the logging module (standard setups, funky use cases), but it also defines two functions, X and D, thus: def X(fmt, *args): msg = str(fmt) if args: msg = msg % args sys.stderr.write(msg) sys.stderr.write("\n") sys.stderr.flush() def D(fmt, *args): ''' Print formatted debug string straight to sys.stderr if D_mode is true, bypassing the logging modules entirely. A quick'n'dirty debug tool. ''' global D_mode if D_mode: X(fmt, *args) I use X() for ad hoc right now debugging and D() for turn on at need debugging. Surprisingly handy. Many many of my modules have "from cs.logutils import X, D" at the top. Cheers, Cameron Simpson "How do you know I'm Mad?" asked Alice. "You must be," said the Cat, "or you wouldn't have come here."