pport and interest in pyparsing!
-- Paul McGuire
--
http://mail.python.org/mailman/listinfo/python-list
Pyparsing 2.0.1 fixes this incompatibility, and should work with all versions
of Python 2.6 and later.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
With the release of version 2.0.0/1.5.7, pyparsing has now officially switched
to Python 3.x support as its default installation environment. Python 2.x users
can install the latest 1.5.7 release. (If you're using easy_install, do
"easy_install pyparsing==1.5.7".)
I'm taking this opportunity to
After about 10 months, there is a new release of pyparsing, version
1.5.6. This release contains some small enhancements, some bugfixes,
and some new examples.
Most notably, this release includes the first public release of the
Verilog parser. I have tired of restricting this parser for
commerci
"googleboy" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi.
>
> I am trying to collapse an html table into a single line. Basically,
> anytime I see ">" & "<" with nothing but whitespace between them, I'd
> like to remove all the whitespace, including newlines. I've read the
> h
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> > timeit -s "import test" "test.test3()"
> 100 loops, best of 3: 6.73 msec per loop
>
> > timeit -s "import test" "test.test4()"
> 1 loops, best of 3: 27.8 usec per loop
>
> that's a 240x slowdown. hmm.
>
>
>
>
W
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all
> I am a newbie and I just saw a ongoing thread on Fileprocessing which
> talks abt config parser.
> I have writen many pyhton program to parse many kind of text files by
> using string module and regex. But after reading that con
"Mohammed Smadi" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi;
>
> Does anyone know if we can call matlab for a python or bash script while
> feeding the matlab script some command line arguments? I have an
> interactive matlab script which i want to automate by feeding the arg
[EMAIL PROTECTED] wrote:
> What is the way for replacing in a string from . to . the sentence?
> for example:
> "been .taken. it may be .left. there,
> even if the .live coals were not. cleared"
> I want to do this-> replace(\.(.*)\.,\.start (1) end\.)
> result:
> "been .start taken end. it may
"Raw string fu"? A new martial art?
--
http://mail.python.org/mailman/listinfo/python-list
"Ben O'Steen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Scenario:
=
Using PyGame in particular, I am trying to write an application that will
run a scripted timeline of events, eg at 5.5 seconds, play xxx.mp3 and put
the image of a ball on screen, at 7.8 seconds move the
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hey there,
>
> i have a small app that i am going to need to get information from a
> few tables on different websites. i have looked at urllib and httplib.
> the sites i need to get data from mostly have this data in tables. So
> that,
"David Rasmussen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> If I have a string that contains the name of a function, can I call it?
> As in:
>
> def someFunction():
> print "Hello"
>
> s = "someFunction"
> s() # I know this is wrong, but you get the idea...
>
> /David
Lookup th
They have
a very good UML tool that has a Python plugin. I'd recommend the
Professional Edition - the code reverse-engineering is like magic.
Not open source or free, though. EA Pro is US$199, Academic license is
US$105. But compare to Rational at $US000's, it is a great value f
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey there,
> i have a text file with a bunch of values scattered throughout it.
> i am needing to pull out a value that is in parenthesis right after a
> certain word,
> like the first time the word 'foo' is found, retrieve the values in
"Claire McLister" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
We've been working with Google Maps, and have created a web service to
map origins of emails to a group. As a trial, we've developed a map of
emails to this group at:
http://www.zeesource.net/maps/map.do?group=668
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi folks,
>
> I've been trying to write a PLY parser and have run into a bit of
> bother.
>
> At the moment, I have a RESERVEDWORD token which matches all reserved
> words and then alters the token type to match the reserved word that
>
"Ben Finney" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Xiao Jianfeng <[EMAIL PROTECTED]> wrote:
> > I need to print a long sting, which is two long so it must expand
> > two lines.
>
> How is this string being constructed in the source? If it exists as a
> single long string, wh
"Inyeol Lee" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm trying to extract module contents from Verilog, which has the form
> of;
>
> module foo (port1, port2, ... );
>
> // module contents to extract here.
> ...
>
> endmodule
>
> To extract the module
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I've got a list of word substrings (the "tokens") which I need to align
> to a string of text (the "sentence"). The sentence is basically the
> concatenation of the token list, with spaces sometimes inserted beetween
>
astarocean wrote:
> using pyparsing to deal with nested tables , wanna keep table's
> structure and propertys .
> but program was chunked with the tag of inner table.
>
> have any ideas?
>
> here's the program
>
>
> from pyparsing import *
<... snip ...>
>
> tablePattern = Forward()
<... sn
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I want to define a rule for a line that does NOT start with a given
> Literal. How do I do that? I try the following and my program just hang
> there:
>
> BodyLine = ~Literal("HTTP/1.1") + restOfLine
>
> Thanks,
> Khoa
>
Khoa -
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi Paul,
>
> I am trying to extract HTTP response codes from a HTTP page send from
> a web server. Below is my test program. The program just hangs.
>
> Thanks,
> Khoa
> ##
>
>
Khoa -
T
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Aahz wrote:
> > Trust the computer, the computer is your friend.
>
> However, the computer isn't a fuckin' mind reader.
>
> If you're going to post source code on the usenet, don't
> have lines longer than 72 characters. Otherwise you'
"Martin MOKREJ©" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
> I have sets.Set() objects having up to 20E20 items,
> each is composed of up to 20 characters. Keeping
> them in memory on !GB machine put's me quickly into swap.
> I don't want to use dictionary approach, as I d
"McBooCzech" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Newbie in Python.
> I did copy the whole script form the web and save it as para1.py. I did
> download pyparsing module and save it to
> C:\\Python23\\Lib\\pyparsing122.
> I did run following script:
>
> import sys
> sys.pat
"kpp9c" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> still working on it and also fixing the input data. I think for
> simplicity and consistency's sake i will have *all* time values input
> and output as hh:mm:ss maybe that would be easier but i have a few
> thousand find and
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> man, now that is beautifully done. Paul, I wish I knew about pyparsing
> a while ago. I could have used it in a few projects. :)
>
Thanks for the compliment! I'll be the first to admit that pyparsing can be
a bit persnickety in some ap
"Henrik Holm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am just starting to learn Python, mostly by going through the examples
> in Dive Into Python and by playing around.
>
> Quite frequently, I find the need to iterate over two sequences at the
> same time, and I have a bit
"It's me" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Okay, I give up.
>
> What's the best way to count number of items in a list?
>
> For instance,
>
> a=[[1,2,4],4,5,[2,3]]
>
> I want to know how many items are there in a (answer should be 7 - I don't
> want it to be 4)
>
I've
"Frans Englich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> As continuation to a previous thread, "PyChecker messages", I have a
question
> regarding code refactoring which the following snippet leads to:
>
> > > runner.py:200: Function (detectMimeType) has too many returns (11)
Despite the regexp alternatives, I refuse to post a pyparsing solution to
this! :)
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
"Lucas Raab" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I'm done porting the C code, but now when running the script I
> continually run into problems with lists. I tried appending and
> extending the lists, but with no avail. Any help is much appreciated
> Please see both the Py
"Michael Hoffman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michael Hoffman wrote:
> > Paul McGuire wrote:
> >> So "A" == 'a' is true in Python, not true in C.
> > I think you meant:
> >
> > >>>
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> An implementation of what you want can be found here:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52558
>
I think this recipe pre-dates the introduction of __new__ in Python.
How about something like this (requires the nam
"Kent Johnson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Martin Häcker wrote:
> >
> >> Hi there,
> >>
> >> I just tried to run this code and failed miserably - though I dunno
> >> why. Could any of you please enlighten me why this doesn't work?
>
> Here is a simpler test case.
"Jay donnell" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a short multi-threaded script that checks web images to make
> sure they are still there. I get a segmentation fault everytime I run
> it and I can't figure out why. Writing threaded scripts is new to me so
> I may b
"TB" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> Is there an elegant way to assign to a list from a list of unknown
> size? For example, how could you do something like:
>
> >>> a, b, c = (line.split(':'))
> if line could have less than three fields?
>
> Thanks,
> TB
>
I
"Benji99" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Basically, I'm getting a htmlsource from a URL and need to
> a.) find specific URLs
> b.) find specific data
> c.) with specific URLs, load new html pages and repeat.
>
>
> Basically, I want to search through the whole strin
"Jamey Cribbs" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Paul Rubin wrote:
> > That's cute, especially the part about using Python expressions
> > instead of SQL to express queries. I don't see anything in the info
> > page about what happens when you have multiple clients upda
Here's a hybrid solution, using pyparsing to parse your input pattern
string (p), and transforming it into a regexp string. Then uses
re.match using the regexp to process string (s), and then builds a
dictionary from the matched groups.
Download pyparsing at http://pyparsing.sourceforge.net.
--
This recipe that I submitted to the Python Cookbook
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/223611)
describes a technique for doing this. I use the example of creating
Color objects for plotting to a bitmap, using either R,G,andB values,
or a single integer representing the RGB en
Using an RDBMS is no cure-all for deadlocks - I can just as easily
deadlock with an RDBMS as with my own threads and locks, probably
easier.
I try to pick up crumbs of knowledge from my co-workers, and one of the
smarter ones gave me this rubric for testing for deadlocks. You need 3
things to cre
Get Tim Golden's wmi module
(http://tgolden.sc.sabren.com/python/wmi.html). I recently had to help
my brother remove some spyware, and so I used some of the example that
came with WMI to read through the registry to extract startup keys,
services, etc.
Even if your users aren't sophisticated enou
My first thought is "make sure that subclassing str is really what you
want to do." Here is a place where I have a subclass of str that
really is a special kind of str:
class PaddedStr(str):
def __new__(cls,s,l,padc=' '):
if l > len(s):
s2 = "%s%s" % (s,padc*(l-len(s)))
Dang, that class should be:
class PaddedStr(str):
def __new__(cls,s,l,padc=' '):
if l > len(s):
s2 = "%s%s" % (s,padc*(l-len(s)))
return str.__new__(cls,s2)
else:
return str.__new__(cls,s)
-- Paul
--
http://mail.python.org/mailman/listin
No need to update __getitem__, since the modified __setitem__ drops in
the reverse values. But __delitem__ needs overriding, and some special
guard needs to be added to __setitem__ to prevent orphaning any old
value:key entries.
-- Paul
Here's one possible solution:
class SymmetricDict(dict):
>From purely Python terms, there is a distinction that one of these
classes (PaddedStr) is immutable, while the other is not. Python only
permits immutable objects to act as dictionary keys, so this would one
thing to differentiate these two approaches.
But on a more abstract, implementation-inde
Look at the related post, on keeping key-key pairs in a dictionary.
Based on our discussion in this thread, I created a subclass of dict
called SymmetricDict, that, when storing symDict["A"] = 1, implicitly
saves the backward looking symDict[1] = "A".
I chose to inherit from dict, in part just to
Man, this is not my week! Another bug in my posted code! The posted
version of SymmetricDict fails when adding an entry in which the key
equals the value. First bug is in __setitem__ in which the insertion
is done twice, which is wasteful but benign. The second bug is in
__delitem__, which thro
Here's a pyparsing version of this, that may be easier to maintain long
term (although if you have your heart set on learning regexp's, they
will certainly do the job). Note that in pyparsing, you don't have to
spell out where the whitespace goes - pyparsing's default logic assumes
that whitespace
Lee C -
Here is a technique for avoiding the if-elseif-elseif...-else method
for building objects. It is a modified form of ChainOfResponsibility
pattern, in which you have a collection of factory methods that all
have a common signature, or a collection of Factory classes that all
implement a "m
Ok, I'm glad you guys liked that design pattern. Here are a few
additional footnotes:
1. As George mentions, the order of the converters is *very* important,
especially in this particular case. One might question whether '1+0j'
would convert to a complex or an int - my first thought was to make
('abc') is not a tuple - this is an unfortunate result of using ()'s as
expression grouping *and* as tuple delimiters. To make ('abc') a
tuple, you must add an extra comma, as ('abc',).
>>> list( ('abc',) )
['abc']
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
See definition of splitlines().
(http://docs.python.org/lib/string-methods.html)
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
David -
I'm not getting the same results. Run this test program:
---
import pyparsing as pp
import sys
def test(s):
results = pp.OneOrMore( pp.Word(pp.alphas) ).parseString( s )
print repr(s),"->",list(results)
print "Python version:", sys.version
print "pyparsing version:",
John -
I just modified my test program BNF to use ZeroOrMore instead of
OneOrMore, and parsed an empty string. Calling list() on the returned
results gives an empty list. What version of pyparsing are you seeing
this None/object/list behavior?
-- Paul
--
http://mail.python.org/mailman/listinf
Modified version of test program, to handle empty strings -> empty
lists.
import pyparsing as pp
import sys
def test(s):
results = pp.ZeroOrMore( pp.Word(pp.alphas) ).parseString( s )
print repr(s),"->",list(results)
print "Python version:", sys.version
print "pyparsing version:", pp.__v
Lee,
Interesting idea, but I think the technique of "inherit from MF to
automatically add class to the test chain" is a gimmick that wont
scale.
Here are some things to consider:
- I'm not keen on the coupling of forcing your A,B,etc. classes to
inherit from MF. Especially in a duck-typing lang
Lee -
Bruce Eckel's observation:
"the above scaffolding of Obstacle, Player and GameElementFactory
(which was translated from the Java version of this example) is
unnecessary - it's only required for languages that have static
type checking. As long as the concrete Python classes follow the form
Steve -
Good catch - in v1.3, I added some Unicode support for pyparsing,
although I have not gotten much feedback that anyone is using it, or
how well it works. So it is preferable to test against basestring
instead of str.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
I'd propose a pyparsing implementation, but you don't give us many
specifics. Is there any chance you could post some sample data, and
one or two of the regexps you are using for matching?
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Well, this doesn't have the terseness of an re solution, but it
shouldn't be hard to follow.
-- Paul
#~ This is a very crude first pass. It does not handle nested
#~ ()'s, nor ()'s inside quotes. But if your data does not
#~ stray too far from the example, this will probably do the job.
#~ Down
I have never written a line of Lisp or Scheme, so it took me a while to
grok "lambda" as a synonym for "expression to be evaluated later". I
then thought it was similar to Smalltalk's functional closures, since
you can define local arguments at the beginning of the block, and then
write the body o
Your elaboration on what problem you are actually trying to solve gave
me some additional insights into your question. It looks like you are
writing a Python-HTML templating system, by embedding Python within
HTML using ... tags.
As many may have already guessed, I worked up a pyparsing treatment
Forgot to mention: Download pyparsing at
http://pyparsing.sourceforge.net.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Is getCenter a function? If so, you need to invoke distance using:
dist = self.distance( n.getCenter(), newElement )
Of course, that is assuming that newElement is a local variable of type
list/tuple/etc.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
I'm not intimate with Python's C/C++ implementation, but is it possible
that your modified code may not be implementation portable? For
instance, if some calculation of the size of the object is required,
inherited classes may layout data differently than contained classes
would, especially if cla
Pyparsing includes a sample program for extracting URLs from web pages.
You should be able to adapt it to this problem.
Download pyparsing at http://pyparsing.sourceforge.net
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
"The best laid plans o' mice an' men / Gang aft a-gley"
So said Robert Burns (who really should do something about that speech
impediment!). And so said I about 6 weeks ago, when I thought that I
would leave pyparsing alone for awhile, after the 1.3.1 release.
Well, here we are, and I'm announci
Garn! Twa' the de'ils wairk! I wad be laith to misquo' the Sco'ish
Bard!
I was trying to make sure I spelled "a-gley" - I lapsed into the
common, but incorrect, quotation.
(http://www.robertburns.org/works/75.shtml)
Thanks!
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Dave -
Check out the URL extractor example that ships with pyparsing. It
handles many kinds of URL formats.
Download pyparsing at pyparsing.sourceforge.net.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Sounds more like fighting fire with... water?
Sounds good to me.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Or use pyparsing, and do both at the same time (that spark example
looks like a lot of work!).
Download pyparsing at http://pyparsing.sourceforge.net.
-- Paul
from pyparsing import *
text = """
outer {
inner1 { ...1 }
inner2 { ...2 }
}
simple { ...3 }
null {}
There are several HTML scraping examples that ship with pyparsing,
including a URL extractor, temperature display, and NTP server
extractor (this last is probably closest to your question).
Download pyparsing at http://pyparsing.sourceforge.net.
-- Paul
--
http://mail.python.org/mailman/listinf
Just because a hosting service doesn't list Python on their web page
doesn't mean that it's not available. My company's service
(LunarPages) supports Python, and only recently has it started
appearing on their online literature.
Once you find your service based on price/support/etc., send them an
If your re demands get more complicated, you could take a look at
pyparsing. The code is a bit more verbose, but many find it easier to
compose their expressions using pyparsing's classes, such as Literal,
OneOrMore, Optional, etc., plus a number of built-in helper functions
and expressions, inclu
Get epydoc from SourceForge (http://epydoc.sourceforge.net/). It will
auto-generate beautiful HTML doc pages for your Python classes, using
the information you have inserted as the doc strings for your classes
and methods. I use it to generate the pyparsing documentation, and it
works very well f
The pyparsing distribution includes epydoc-generated class
documentation, and a few example programs. Dave Kuhlman has a nice
HOWTO at
http://www.rexx.com/~dkuhlman/python_201/python_201.html#SECTION00760
Drop me a note if you are looking for some specific tips or techniques.
(I'
Please look through this example code, and the comments. If I've
misspoken, please anyone correct my errors.
-- Paul
class OldStyleClass:
"""A definition of an old style class."""
pass
class NewStyleClass(object):
"""Note that NewStyleClass explicitly inherits from object. This
Instance variables are typically defined in __init__(), but they can be
added to an object anywhere. The only exception is when defining the
magic __slots__ class variable to pre-define what the allowed instance
variables can be.
class A:
pass
a = A()
a.instVar1 = "hoo-ah"
a.instVar2 = "another
I just did this sort of thing the other day!
Your database only accepts ints for BH, but remember, you are building
an SQL *string* to be executed. To show SQL that your BH value is an
int, not a string, do not enclose it in quotes.
(Another style hint: don't name dict's "dict", as this will mas
Try this, its a bit more readable than your re.
from pyparsing import Word,nums,Literal,replaceWith
data1=''
# a number is a word composed of nums, that is, the digits 0-9
# your search string is looking for a number between an '=' and '&'
EQUALS = Literal("=")
AMPER = Literal("&")
number =
Rex -
If what you are looking for is a monitor of calls to a certain
function, check out this decorator example from the Python Wiki:
http://wiki.python.org/moin/PythonDecoratorLibrary?highlight=%28Decorator%29#head-d4ce77c6d6e75aad25baf982f6fec0ff4b3653f4
This will allow you to very quickly tur
Given the example re that you've been trying to get working, here is a
pyparsing approach that might be more, um, approachable.
Unfortunately, since I don't have the URL of the page you are working
with, I'm unable to test this before posting.
Good luck,
-- Paul
# getMP3s.py
# get pyparsing at ht
Just as with re you were using "?P" to assign the matching text to
the variable "xxx", pyparsing allows you to associate a name with an
element of your grammar using setResultsName.
Here is your original re:
r=re.compile(ur'valign=top>(?P\d{1,2})]*>\s{0,2}'
ur''
ur'(?P.+)',re.UNICODE|re.IG
Oof! That should be:
mp3entry = valign + number.setResultsName("number") + tdEnd + \
tdStart + SkipTo(aStart) + aStart + \
SkipTo(tdEnd).setResultsName("name") + tdEnd
--
http://mail.python.org/mailman/listinfo/python-list
Well, you are returning prematurely from a for loop, so that is why you
are only getting the first value. Its just like:
for i in range(100):
return i
It doesn't matter how big the range is you are iterating over, you'll
return on the first element and that's it.
If what you want is the
I just reviewed what the re "\s" signifies: whitespace. This is easy,
pyparsing ignores all intervening whitespace by default. So mp3Entry
simplfies to:
mp3entry = valign + number.setResultsName("number") + tdEnd + \
tdStart + aStart + \
SkipTo(tdEnd).setResultsName("
Steve -
Is there a chance you could post a before and after example, so we can
see just what you are trying to do instead of talking conceptually all
around it and making us guess? If you are just doing some spot
translations of specific values in an HTML file, you can probably get
away with a si
Here's a pyparsing program that reads my personal web page, and spits
out HTML with all of the HREF's reversed.
-- Paul
(Download pyparsing at http://pyparsing.sourceforge.net.)
from pyparsing import Literal, quotedString
import urllib
LT = Literal("<")
GT = Literal(">")
EQUALS = Literal("=")
Mike -
Thanks for asking. Typically I hang back from these discussions of
parsing HTML or XML (*especially* XML), since there are already a
number of parsers out there that can handle the full language syntax.
But it seems that many people trying to parse HTML aren't interested in
fully parsing a
Perhaps a bit more verbose than your Perl regexp, here is a decoder
using pyparsing.
-- Paul
# download pyparsing at http://pyparsing.sourceforge.net
from pyparsing import Word,Combine
# define grammar for matching encoded characters
hexnums = "0123456789ABCDEFabcdef"
encodedChar = Combine( "%"
Here's the pyparsing rendition - about 24 lines of code, and another 30
for testing.
For reference, here's the JSON "bnf":
object
{ members }
{}
members
string : value
members , string : value
array
[ elements ]
[]
elements
value
elements , value
value
string
This works (note relocated right paren at (?(second) ):
#!/usr/bin/env python
import re
original_pattern = re.compile(r"""
(?P(first))
(?(first)
(?P(second))
)
(?(second)
(?P(third))
)
""", re.VERBOSE)
pattern = re.compile(r"""
(?P(first))
Are you sure this is really slowing down your program? "Many hundreds
of lines" is not nearly enough to start Python breathing hard. I have
been really impressed with just how quickly Python is able to do file
input and processing, zipping through whole megs of data in just
seconds.
How are you
Google for "optimized regexp" returns:
http://laurent.riesterer.free.fr/regexp/make-regexp.html
http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/
There are several more links, but all appear to be written in languages
other than Python. Perhaps you could port one of them.
It also seems tha
Oh, please! Even the most lopsided, opinionated, um, person could have
tried, oh, maybe, "time" as a possible module for this function?
What next? "Is there a module or class that will convert 'I have no
shame. ' to upper case, AND trim the trailing whitespace?" (Hint: it
has to do with 'strin
Even though you are using re's to try to look for specific substrings
(which you sort of fake in by splitting on "Identifier", and then
prepending "Identifier" to every list element, so that the re will
match...), this program has quite a few holes.
What if the word "Identifier" is inside one of t
It's not free, but it is pretty cheap considering all it can do. Check
out Enterprise Architect (with the free add-in for Python) from
www.sparxsystems.com.au. Pro version license is US$180 or so, but they
may have a student license for less that you could use.
-- Paul
--
http://mail.python.or
1 - 100 of 1267 matches
Mail list logo