473,503 Members | 10,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable-width lookbehind

For years now Python has not supported variable-length lookbehinds.
I'm just curious whether there are any plans to change this in Python
3.0, or before, or after. It seems that Perl 6 will allow variable-
width lookbehinds (see http://dev.perl.org/perl6/doc/design/apo/A05.html
and http://dev.perl.org/perl6/rfc/72.html ).

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
Nov 17 '07 #1
6 2955
"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrites:
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. Basically it sounds like an even uglier form of
regexp backtracking than what we have now. Regexps are just not the
right framework for implementing such complex parsers. We should
instead have some more general parser library instead of keeping on
jamming more crap into regexps. There's a famous Zawinski quote that
I won't repeat here since I don't want to wear it out.
Nov 17 '07 #2
Paul Rubin wrote:
"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrites:
> 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.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
Nov 18 '07 #3
OKB (not okblacke) wrote:
Paul Rubin wrote:

>"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrites:
>> 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

Nov 18 '07 #4
Gary Herron wrote:
OKB (not okblacke) wrote:
>Paul Rubin wrote:

>>"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrites:

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*.
Well, it doesn't really change the potential for unreadability. It
just allows people to put existing unreadable (or readable) regexps
inside a particular kind of group.
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.
Yeah, this is what I was expecting, and it's a valid point. I was
just wondering if this had ever been floated before. I personally have
nowhere near the chops to write something like a regex engine (that's
why I like using Python -- it's got one built in!).

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
Nov 20 '07 #5
"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrote:
>
For years now Python has not supported variable-length lookbehinds.
I'm just curious whether there are any plans to change this in Python
3.0, or before, or after. It seems that Perl 6 will allow variable-
width lookbehinds (see http://dev.perl.org/perl6/doc/design/apo/A05.html
and http://dev.perl.org/perl6/rfc/72.html ).
If I may be just a bit catty, your last sentence may actually be the best
reason NOT to include it in Python 3.0. Perl 6 has become a worthy
successor to ALGOL 68 and PL/I. They are attempting to pack in every
feature that has ever been requested by every person in the known universe.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 20 '07 #6
Tim Roberts wrote:
"OKB (not okblacke)" <br************@NObrenSPAMbarn.netwrote:
>>
For years now Python has not supported variable-length
lookbehinds.
I'm just curious whether there are any plans to change this in
Python 3.0, or before, or after. It seems that Perl 6 will allow
variable- width lookbehinds (see
http://dev.perl.org/perl6/doc/design/apo/A05.html and
http://dev.perl.org/perl6/rfc/72.html ).

If I may be just a bit catty, your last sentence may actually be
the best reason NOT to include it in Python 3.0. Perl 6 has become
a worthy successor to ALGOL 68 and PL/I. They are attempting to
pack in every feature that has ever been requested by every person
in the known universe.
That's as may be, but if I may be a bit redundant with myself, I'd
like to reiterate that I don't see this is as a new "feature". Regular
expressions already exist in Python. Lookbehinds already exist in
Python regular expressions. The only thing that doesn't exist is the
ability to use arbitrary regular expressions in lookbehinds, and my
understanding is that this is just because regular expression engines
have typically been implemented in a way that makes this hard to add on.
In other words, what I'm describing isn't an extension of what regular
expressions are, it's just the lifting of a bothersome implementation-
based restriction on one aspect of their use.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
Nov 20 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4534
by: Scott | last post by:
I have an XML Document in a format like: <Variable name="Bob">ABCDEFG</Variable> <Variable name="Steve">QWERTYUI</Variable> <Variable name="John">POIUYTR</Variable> <Variable...
4
3226
by: Frederik Sørensen | last post by:
I include a xslt stylesheet with variables for all the error messages in my system. <xsl:variable name="Banner_error_1"> errormessage 1 for banner </xsl:variable> <xsl:variable...
134
7747
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
10
2226
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
23
19133
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
3
3943
by: rls03 | last post by:
I have the following which creates a variable containing a relative path where <xsl:value-of select="."/returns a portion of the filename: <xsl:variable...
1
25620
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
2
3660
by: Florian Loitsch | last post by:
hi, What should be the output of the following code-snippet? === var x = "global"; function f() { var x = 0; eval("function x() { return false; }"); delete x; alert(x); }
37
5426
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
112
5350
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.