Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'context:': 0.09; 'decorator': 0.09; 'subject:python': 0.10; '.py': 0.16; 'ast': 0.16; 'breakpoint': 0.16; 'class)': 0.16; 'debugger': 0.16; 'debugging,': 0.16; 'directive': 0.16; 'filename)': 0.16; 'revise': 0.16; 'x-mailer:evolution 2.22.3.1': 0.16; 'syntax': 0.16; 'extension': 0.17; 'programming': 0.20; 'cc:no real name:2**0': 0.21; 'file,': 0.21; '(or': 0.22; 'produces': 0.23; 'tool,': 0.23; 'unlikely': 0.23; 'elements': 0.24; 'receives': 0.24; 'tree': 0.25; 'cc:2**0': 0.26; 'classes': 0.26; 'module': 0.26; 'function': 0.27; 'column': 0.28; "i'm": 0.28; 'interact': 0.29; 'lines': 0.30; 'comments?': 0.30; 'error': 0.30; 'source': 0.32; 'contributed': 0.32; 'there': 0.33; 'object': 0.33; 'file': 0.34; 'numbers.': 0.34; 'to:addr:python-list': 0.35; 'two': 0.36; 'but': 0.37; 'shows': 0.37; 'using': 0.37; 'could': 0.38; 'useful': 0.38; 'files': 0.39; 'change': 0.40; 'to:addr:python.org': 0.40; 'achieve': 0.61; 'header:Message- Id:1': 0.62; 'number.': 0.66; 'receive': 0.68; 'received:38': 0.76; 'problematic': 0.84; 'received:10.0.2': 0.84; 'received:38.99': 0.91 Subject: #line in python From: Ross Boylan To: python-list@python.org Content-Type: text/plain Organization: UCSF Date: Sat, 18 Feb 2012 16:54:18 -0800 Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Spam_score: -4.3 X-Spam_score_int: -42 X-Spam_bar: ---- X-Spam_report: (-4.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 AWL AWL: From: address is in the auto white-list Cc: ross@biostat.ucsf.edu X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329613948 news.xs4all.nl 6850 [2001:888:2000:d::a6]:39135 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20601 The ast module shows that elements of the syntax tree have line and column numbers. Would it be sensible to attempt to revise them to achieve effects like the #line directive in C? Context: Using noweb, a literate programming tool, which from a source file foo.nw produces foo.py. The lines in the two files may be in completely different sequenes. For debugging, it is useful to receive error reports that refer to the original line number in foo.nw. I am not sure how such rewriting would interact with debugger commands that set a breakpoint at a file and line number. I'm also not sure it would change the reported line numbers of errors. The lack of a file name could be problematic if multiple sources contributed to the same .py file, but that is an unlikely scenario. As an extension or alternate, could there be a decorator like @source_line(lineno, filename) for classes and methods that could do the conversion on the fly? I don't know if there's a way to go from the function (or class) object the decorator receives to the AST. Comments? Ross Boylan