472,950 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

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 2930
"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
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.