Prev: any python libraries for rendering open office spreadsheet to html
Next: what's the diffence between "RECENT" and "UNSEEN" in imaplib?
From: moerchendiser2k3 on 19 Mar 2010 09:12 In my case I call a funcion and I would like to get the line where the function returned. for instance: def my_function(): return 3 So I would like to get line 2(in C) somehow.
From: Stefan Behnel on 19 Mar 2010 10:11 moerchendiser2k3, 19.03.2010 14:12: > In my case I call a funcion and I would like to get the line > where the function returned. > > for instance: > > > def my_function(): > return 3 > > So I would like to get line 2(in C) somehow. Ok, so you're looking for the C-level trace function in CPython, I guess. Could you explain why you want to know the line number? Stefan
From: moerchendiser2k3 on 19 Mar 2010 22:01 Yes, the user is able to set a file which contains a function that does what the user wants. But in a case, I expect a special return value of this function. So, I need to tell him, in which file/line the error occured, otherwise he dont know where to look. Imagine he set 20 files, and all of them have implemented a special function. So he wouldnt know where to check for the error. Bye, moerchendiser2k3
From: Stefan Behnel on 20 Mar 2010 05:44
moerchendiser2k3, 20.03.2010 03:01: > Yes, the user is able to set a file which contains a function that > does what the user wants. > But in a case, I expect a special return value of this function. Ah, ok, that was the important piece of information that you omitted from your previous posts. So what you actually do is call a user provided function and you want to report errors back to the user if the function does not behave as expected by the (plugin) interface, and not only when it raises an exception itself. You might want to read this: http://catb.org/~esr/faqs/smart-questions.html > So, I need to tell him, in which file/line the error occured, > otherwise he dont know where to look. > > Imagine he set 20 files, and all of them have implemented a special > function. So he wouldnt know where to check for the error. Well, you can easily get at the module file path and the function name through introspection of the function, just as you would in Python. That should be enough information to present to the user. I don't see why you would want to add the exact line number of the return statement. The inner workings of the user function you call are up to the user, after all. Again, take a look at Cython, where you can do the introspection in Python code. Stefan |