2007年09月05日 星期三 20:01
一段代码被try ... except Exception,e 后,有什么办法获得抛出异常的具体位置或者行号呢?!如果直接print e 只能看到 异常信息而不能看到详细的出错位置 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070905/dece4805/attachment.html
2007年09月05日 星期三 20:23
Cyril_Gmail wrote: > Ò»¶Î´úÂë±»try ... except Exception,e ºó£¬ÓÐʲô°ì·¨»ñµÃÅ׳öÒì³£µÄ¾ßÌåλ > ÖûòÕßÐкÅÄØ£¿£¡Èç¹ûÖ±½Óprint e Ö»ÄÜ¿´µ½ Òì³£ÐÅÏ¢¶ø²»ÄÜ¿´µ½ÏêϸµÄ³ö´íλÖà traceback.print_exc() ? Cheers, -- Xin LI <delphij在delphij.net> http://www.delphij.net/ FreeBSD - The Power to Serve! -------------- 下一部分 -------------- Ò»¸ö·ÇÎı¾¸½¼þ±»Çå³ý... ·¢ÐÅÈË: %(who)s Ö÷Ìâ: %(subject)s ÈÕÆÚ: %(date)s ´óС: 249 Url: http://python.cn/pipermail/python-chinese/attachments/20070905/27740d2b/attachment.pgp
2007年09月06日 星期四 09:46
的确不不错,有没有人测过,traceback 会不会占用很多资源?! On 9/5/07, LI Xin <delphij at delphij.net> wrote: > > Cyril_Gmail wrote: > > 一段代码被try ... except Exception,e 后,有什么办法获得抛出异常的具体位 > > 置或者行号呢?!如果直接print e 只能看到 异常信息而不能看到详细的出错位置 > > traceback.print_exc() ? > > Cheers, > -- > Xin LI < delphij at delphij.net> http://www.delphij.net/ > FreeBSD - The Power to Serve! > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070906/cfe0292c/attachment.htm
2007年09月06日 星期四 09:50
On 9/6/07, Cyril_Gmail <terry6394在gmail.com> wrote: > 的确不不错,有没有人测过,traceback 会不会占用很多资源?! > 应该不占.异常信息里面其实都有,在sys模块中,traceback只不过是可以进行更细致的处理,比如自行加工等. -- I like python! UliPad <>: http://code.google.com/p/ulipad/ My Blog: http://www.donews.net/limodou
2007年09月06日 星期四 14:09
我用下面的代码测试了一下,似乎没有速度变化。(也不知道这样测试有没有意义) # -*- coding: cp936 -*- #import traceback import time def f1(): str("1") f2() def f2(): str("2") f3() def f3(): str("3") try: startTime = time.time() for i in xrange(10e6): str(i) f1() endTime = time.time() print "Time:", (endTime - startTime) except Exception, e: # print traceback.format_exc() pass 结果: Time: 27.9220001698 ,导入 traceback, 并在后面添加 Time: 28.0309998989 不导入traceback, 并注释print traceback.format_exc() On 9/6/07, limodou <limodou at gmail.com> wrote: > > On 9/6/07, Cyril_Gmail <terry6394 at gmail.com> wrote: > > 的确不不错,有没有人测过,traceback 会不会占用很多资源?! > > > 应该不占.异常信息里面其实都有,在sys模块中,traceback只不过是可以进行更细致的处理,比如自行加工等. > > -- > I like python! > UliPad <>: http://code.google.com/p/ulipad/ > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070906/5a740783/attachment.html
2007年09月06日 星期四 14:16
你的目的是什么? On 9/6/07, Cyril_Gmail <terry6394在gmail.com> wrote: > 我用下面的代码测试了一下,似乎没有速度变化。(也不知道这样测试有没有意义) > # -*- coding: cp936 -*- > #import traceback > import time > def f1(): > str("1") > f2() > > def f2(): > str("2") > f3() > > def f3(): > str("3") > > try: > startTime = time.time() > for i in xrange(10e6): > str(i) > f1() > endTime = time.time() > print "Time:", (endTime - startTime) > except Exception, e: > # print traceback.format_exc() > pass > > 结果: > Time: 27.9220001698 ,导入 traceback, 并在后面添加 > Time: 28.0309998989 不导入traceback, 并注释print traceback.format_exc() > > > > On 9/6/07, limodou <limodou在gmail.com> wrote: > > > > On 9/6/07, Cyril_Gmail <terry6394在gmail.com> wrote: > > > 的确不不错,有没有人测过,traceback 会不会占用很多资源?! > > > > > 应该不占.异常信息里面其实都有,在sys模块中,traceback只不过是可以进行更细致的处理,比如自行加工等. > > > > -- > > I like python! > > UliPad <>: > http://code.google.com/p/ulipad/ > > My Blog: http://www.donews.net/limodou > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > -- I like python! UliPad <>: http://code.google.com/p/ulipad/ My Blog: http://www.donews.net/limodou
2007年09月07日 星期五 01:34
目的是想知道,在程序中使用了traceback是否会影响程序效率。 On 9/6/07, limodou <limodou at gmail.com> wrote: > > 你的目的是什么? > > On 9/6/07, Cyril_Gmail <terry6394 at gmail.com> wrote: > > 我用下面的代码测试了一下,似乎没有速度变化。(也不知道这样测试有没有意义) > > # -*- coding: cp936 -*- > > #import traceback > > import time > > def f1(): > > str("1") > > f2() > > > > def f2(): > > str("2") > > f3() > > > > def f3(): > > str("3") > > > > try: > > startTime = time.time() > > for i in xrange(10e6): > > str(i) > > f1() > > endTime = time.time() > > print "Time:", (endTime - startTime) > > except Exception, e: > > # print traceback.format_exc() > > pass > > > > 结果: > > Time: 27.9220001698 ,导入 traceback, 并在后面添加 > > Time: 28.0309998989 不导入traceback, 并注释print traceback.format_exc() > > > > > > > > On 9/6/07, limodou <limodou at gmail.com> wrote: > > > > > > On 9/6/07, Cyril_Gmail <terry6394 at gmail.com> wrote: > > > > 的确不不错,有没有人测过,traceback 会不会占用很多资源?! > > > > > > > 应该不占.异常信息里面其实都有,在sys模块中,traceback只不过是可以进行更细致的处理,比如自行加工等. > > > > > > -- > > > I like python! > > > UliPad <>: > > http://code.google.com/p/ulipad/ > > > My Blog: http://www.donews.net/limodou > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese at lists.python.cn > > > Subscribe: send subscribe to > > python-chinese-request at lists.python.cn > > > Unsubscribe: send unsubscribe to > > python-chinese-request at lists.python.cn > > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request at lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > > > -- > I like python! > UliPad <>: http://code.google.com/p/ulipad/ > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070907/9b2cdbdc/attachment.html
2007年09月07日 星期五 01:48
On 9/7/07, Cyril_Gmail <terry6394在gmail.com> wrote: > 目的是想知道,在程序中使用了traceback是否会影响程序效率。 > 这纯粹只有调试时使用的招, 调试好了,自然要清除的哪?! > > On 9/6/07, limodou <limodou在gmail.com> wrote: > > 你的目的是什么? > > > > On 9/6/07, Cyril_Gmail <terry6394在gmail.com> wrote: > > > 我用下面的代码测试了一下,似乎没有速度变化。(也不知道这样测试有没有意义) > > > # -*- coding: cp936 -*- > > > #import traceback > > > import time > > > def f1(): > > > str("1") > > > f2() > > > > > > def f2(): > > > str("2") > > > f3() > > > > > > def f3(): > > > str("3") > > > > > > try: > > > startTime = time.time() > > > for i in xrange(10e6): > > > str(i) > > > f1() > > > endTime = time.time() > > > print "Time:", (endTime - startTime) > > > except Exception, e: > > > # print traceback.format_exc() > > > pass > > > > > > 结果: > > > Time: 27.9220001698 ,导入 traceback, 并在后面添加 > > > Time: 28.0309998989 不导入traceback, 并注释print traceback.format_exc () > > > > > > > > > > > > On 9/6/07, limodou <limodou在gmail.com> wrote: > > > > > > > > On 9/6/07, Cyril_Gmail <terry6394在gmail.com > wrote: > > > > > 的确不不错,有没有人测过,traceback 会不会占用很多资源?! > > > > > > > > > > 应该不占.异常信息里面其实都有,在sys模块中,traceback只不过是可以进行更细致的处理,比如自行加工等. > > > > > > > > -- > > > > I like python! > > > > UliPad <>: > > > http://code.google.com/p/ulipad/ > > > > My Blog: http://www.donews.net/limodou > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > > Detail Info: > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > > I like python! > > UliPad <>: > http://code.google.com/p/ulipad/ > > My Blog: http://www.donews.net/limodou > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > -- '''Time is unimportant, only life important! 过程改进的目标不是高品质产品,而是促生靠谱的人的组织! '''http://zoomquiet.org blog @ http://blog.zoomquiet.org/pyblosxom/ wiki @ http://wiki.woodpecker.org.cn/moin/ZoomQuiet scrap @ http://floss.zoomquiet.org share @ http://share.zoomquiet.org douban@ http://www.douban.com/people/zoomq/ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pls. usage OOo to replace M$ Office. http://zh.openoffice.org Pls. usage 7-zip to replace WinRAR/WinZip. http://7-zip.org You can get the truely Freedom 4 software.
Zeuux © 2025
京ICP备05028076号