[Pyrex] Better comment lines in C source?
Phillip J. Eby
pje at telecommunity.com
Thu Aug 26 05:30:25 CEST 2004
At 01:41 PM 8/26/04 +1200, Greg Ewing wrote:
>"Edward K. Ream" <edreamleo at charter.net>:
>
> > C listings are commented by line number:
> >
> > /* "ProjectsA:Python:Pyrex:Demos:primes.pyx":9 */
> >
> > The pyrex source might be more informative:
> >
> > /* while k < kmax: */
>
>Those comments are mostly there for my benefit when I'm debugging the
>compiler. They're easy to produce because every parse tree node has
>information about the source file position. Including the actual
>source would require considerably more work.
from linecache import getline
# ...
print "/* %r:%s */" % (filename, lineno)
print "/* %s */" % getline(filename, lineno)
Isn't it amazing how often some silly little piece of functionality you
need is already buried somewhere in the standard library? ;)
More information about the Pyrex
mailing list