[IPython-dev] Fwd: Status of pre-0.10 reviews and merges

Brian Granger ellisonbg.net@gmail....
Thu Apr 2 22:09:21 CDT 2009


---------- Forwarded message ----------
From: Brian Granger <ellisonbg.net@gmail.com>
Date: Thu, Apr 2, 2009 at 8:09 PM
Subject: Re: [IPython-dev] Status of pre-0.10 reviews and merges
To: Jörgen Stenarson <jorgen.stenarson@bostream.nu>


> Some random thoughts on the refactoring process:
>
> When working on the genutils.py patch I thought that it would be nice to
> have smaller module files because it is somewhat difficult to navigate huge
> modules and sometimes it can be difficult to guess in what module I should
> look for some function.

Yes, partitioning large modules like genutils into more logical
modules is part of my reorganization plans.  Details to follow.

> All uses of from xx import * should be removed. This is one refactoring that
> would really benefit from good test coverage.

Definitely!

> To simplify debugging I have found the following idiom useful when
> re-raising exceptions because it preserves the full traceback:

Yes, this type of thing is helpful.

> import sys
>
> def a():
>    1/0
>
> def b():
>    try:
>       a()
>    except ZeroDivisionError, x:
>        raise ValueError, None, sys.exc_info()[2]
> def c():
>    try:
>       a()
>    except ZeroDivisionError, x:
>        raise ValueError
>
>
> From an interactive session after running the prop_traceback.py script:
>
> In [1]: b()
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
>
> C:\python\<ipython console> in <module>()
>
> C:\python\prop_traceback.py in b()
>      9 def b():
>     10     try:
> ---> 11        a()
>     12     except ZeroDivisionError, x:
>     13         raise ValueError, None, sys.exc_info()[2]
>
> C:\python\prop_traceback.py in a()
>      5
>      6 def a():
> ----> 7     1/0
>      8
>      9 def b():
>
> ValueError:
>
> In [2]: c()
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
>
> C:\python\<ipython console> in <module>()
>
> C:\python\prop_traceback.py in c()
>     16        a()
>     17     except ZeroDivisionError, x:
> ---> 18         raise ValueError
>     19
>     20
>
> ValueError:
>
> As you can see when calling b() we get the full traceback up to the a
> function unlike in c() where the traceback terminates in the except cluse. I
> have found this technique very useful when debugging code. I do not know in
> what way this will affect performance or if there are any other drawbacks in
> threaded code or elsewhere...
>
> /Jörgen
>


More information about the IPython-dev mailing list