[wingide-users] Exception Completion idea

Wingware Support support at wingware.com
Thu Jun 17 20:52:34 MDT 2010


Ken Kinder wrote:
> I realize this is probably pretty hard to code, but an excellent 
> feature for auto-completion would to examine the code in the try block 
> and figure out what exceptions could be raised. For example:
>
>     class CustomError(Exception): pass
>
>     def something(): raise CustomError
>
>     try:
>         something()
>     except (auto-completes CustomError with priority above other
>     exceptions):
>
>
> I've seen things similar to this done in Eclipse with Java. Obviously 
> Java's lack of dynamicness makes it easier to analyze, but if it's 
> possible to do with Python, it would be handy.

The idea of trying to track possible exception types as well as return 
value types seems like a good one, although I don't know how well it 
would work in practice.  It might be quite costly to compute since it 
would have to trace the entire possible call graph of a code base and 
the types of everything through that graph in order to decide whether 
something like "a += b" somewhere way down the stack could raise 
TypeError.  It would also run into the limitations of looking into 
extension module code and highly dynamic code so probably could never be 
completely correct in Python.

While I don't know if it's doable, I do think it's a good suggestion.  
The same data collected for this feature might be used in other ways also.

Thanks,

-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com



More information about the wingide-users mailing list