re.finditer

Just just at xs4all.nl
Tue Jul 23 11:42:13 EDT 2002


In article <mailman.1027437514.12145.python-list at python.org>,
 "Sean 'Shaleh' Perry" <shalehperry at attbi.com> wrote:

> > 
> > $ python
> > Python 2.2.1 (#1, Apr  9 2002, 13:10:27)
> > [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import re
> >>>> re.finditer('r+?','library')
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> > AttributeError: 'module' object has no attribute 'finditer'
> > 
> > The command re.finditer is not recognized ! All the other commands
> > work, for instance
> > 
> 
> import re
> regex = re.compile(r'\s'+)
> dir(regex)
> ['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner',
> 'search', 'split', 'sub', 'subn']
> 
> as you can see, finditer() is a method of a regular expression object and is
> not a generic function in the re module.  This may still be a bug because it 
> is
> handy to call regex's directly and not need to compile them.

I think the reason is that "finditer" is not listed in sre's __all__ 
attribute, so it doesn't get exported to re.

Just



More information about the Python-list mailing list