[wingide-users] cannot determine return type of re.match()

Wingware Support support at wingware.com
Tue May 6 09:20:54 MDT 2008

Michael P. Soulier wrote:
> I'm surprised to find that WingIDE cannot determine the type of 'm' in 
> this code.
> import re
> m = re.search(r'foo', bar)
> Doesn't re.search always return a match object or None?

The issue here is the somewhat convoluted way the re module is written,
although I've just found that in Python 2.5 it seems Wing can get to the
search() function via goto-definition and from there via the source
assistant to the correct return value type.  So I suspect we are missing
some inferencing step in the auto-completer's attempts at finding the type.

A work-around would be to do this:

if 0:
         import _sre
         isinstance(m, _sre.MatchObject)

'Course that's not so useful if you have tons of instances of this,
as is often the case.

Anyway, we'll try to fix this.


Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list