RE strings (was: Variable Interpolation - status of PEP 215)
Peter Hansen
peter at engcorp.com
Fri Jun 21 09:32:12 EDT 2002
Daniel Dittmar wrote:
>
> > Cimarron Taylor wrote:
> >> m = re'^EMP:([^,]*),([^,]*),([^,]*),([^,]*)$'.match(line)
> >> if m:
> >> ...
> >>
> >> is much clearer and more maintainable than
> Peter Hansen replied:
> > Given that the only real difference is you skip an import, and
> > at the cost of modifying the language definition in an unusual
> > manner, is there any point to this at all?
>
> The implementation could choose to cache the result of re.compile at module
> level, thus
> - speeding up the 'naive' re usage
> - freeing the programmer from doing the caching in code
Any reason the re.match() method could not do the same, internally?
> I'm still against it, the road to Perl is paved with syntax extensions.
:-)
-Peter
More information about the Python-list
mailing list