Variable-width lookbehind

Gary Herron gherron at islandtraining.com
Sun Nov 18 02:58:36 EST 2007


OKB (not okblacke) wrote:
> Paul Rubin wrote:
>
>   
>> "OKB (not okblacke)" <brenNOSPAMbarn at NObrenSPAMbarn.net> writes:
>>     
>>>          For years now Python has not supported variable-length
>>>          lookbehinds.  
>>>       
>> I'm not sure what that is and the perl links you gave don't work,
>> but it sounds evil. 
>>     
>
>     	The links work fine for me. . .
>
>     	You're not sure what "variable-length lookbehinds" means?  
> Lookbehind is something that Python regexps already have.  You can do 
> "(?<=one)two" to match "two" only if it's preceded by "one", and you can 
> do "(?<!one)two" to match "two" only if it's NOT preceded by "one".  
> What you can't do is "(?<=one|three)two", because Python requires that 
> the lookbehind contain only strings of a fixed length.  What I'm asking 
> about is the possibility of lifting this limitation, to allow the 
> lookbehinds (positive and negative) to contain general regexps.  I don't 
> see how this is in any way evil.
>   
If not *evil*, then how about *unreadable*.   Regular expressions are
powerful, but nearly unreadable as they are.  Allowing them to be even
more complex just gets one step closer to *absolutely unreadable*.

But that's not necessarily a reason to keep it out of the language. 
(Well actually, keeping Python's clarity-of-code goal in mind, it might
be reason enough for some to want to keep it out.)   But this is an all
volunteer community.  Your feature is not in the language because no one
has cared enough to implement it.  Or if some one has implemented it, no
one has found it useful enough to lobby it into the language. 

Are you willing to implement it and lobby for it's inclusion?  If so,
good, we'll look at it.  If not, then perhaps you understand perfectly
why it's not yet included.

Welcome to the world of Open Source!

Gary Herron




More information about the Python-list mailing list