Adjusting filename and line number

B

banshee.welton

Hello,

I'm working with some embedded python and would like to be able to
adjust the reported filename and line number of some embedded user-
written code so that errors returned coincide with things the user
might actually be familiar with.

In perl I could do this by adjusting the filename and line within a
script like so:

foo.pl
------
#!/usr/bin/env perl
#line 1000 "myfile.txt"
this is a syntax error

$ perl foo.pl
Can't locate object method "a" via package "syntax" (perhaps you
forgot to load "syntax"?) at myfile.txt line 1000.

For what it's worth, the same directive also works as a "C"
preprocessor macro.

I have searched for ways of managing this in python, but so far have
not found any way of accomplishing this. Anyone know how it could be
done?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top