Re: Beautiful Soup Looping Extraction Question

2008-03-24 Thread Paul McGuire
On Mar 24, 7:56 pm, Tess [EMAIL PROTECTED] wrote: Anyhow, a simple regex took care of the issue in BS: for i in soup.findAll(re.compile('^p|^div'),align=re.compile('^center| ^left')):     print i But I thought you only wanted certain combinations: My goal is to extract all elements

Re: Pyparsing help

2008-03-23 Thread Paul McGuire
There are a couple of bugs in our program so far. First of all, our grammar isn't parsing the METAL2 entry at all. We should change this line: md = mainDict.parseString(test1) to md = (mainDict+stringEnd).parseString(test1) The parser is reading as far as it can, but then stopping

Re: Pyparsing help

2008-03-22 Thread Paul McGuire
On Mar 22, 4:11 pm, rh0dium [EMAIL PROTECTED] wrote: Hi all, I am struggling with parsing the following data: snip As a side note:  Is this the right approach to using pyparsing.  Do we start from the inside and work our way out or should I have started with looking at the bigger picture (

Re: Pyparsing help

2008-03-22 Thread Paul McGuire
Oof, I see that you have multiple Layer entries, with different qualifying labels. Since the dicts use Layer as the key, you only get the last Layer value, with qualifier PRBOUNDARY, and lose the Layer for METAL2. To fix this, you'll have to move the optional alias term to the key, and merge

Re: Do any of you recommend Python as a first programming language?

2008-03-22 Thread Paul McGuire
On Mar 22, 11:40 am, jmDesktop [EMAIL PROTECTED] wrote: For students 9th - 12th grade, with at least Algebra I.  Do you think Python is a good first programming language for someone with zero programming experience?  Using Linux and Python for first exposure to programming languages and

Re: identifying and parsing string in text file

2008-03-08 Thread Paul McGuire
On Mar 8, 2:02 pm, Nemesis [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: I have a large file that has many lines like this, element tag=300a,0014 vr=CS vm=1 len=4 name=DoseReferenceStructureTypeSITE/element I would like to identify the line by the tag (300a,0014) and then grab the

Re: Parse specific text in email body to CSV file

2008-03-08 Thread Paul McGuire
On Mar 8, 4:20 pm, [EMAIL PROTECTED] wrote: I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to incorporate into a database or CSV file. I want to

Re: Better grammar.txt

2008-03-07 Thread Paul McGuire
On Mar 6, 1:20 pm, Jeroen Ruigrok van der Werven [EMAIL PROTECTED] nomine.org wrote: -On [20080306 19:21], member thudfoo ([EMAIL PROTECTED]) wrote: An error occurred while loading http://www.martinrinehart.com/articles/python-grammar.html: Unknown hostwww.martinrinehart.com Works for me.

Re: Exploring Attributes and Methods

2008-03-06 Thread Paul McGuire
On Mar 6, 1:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi,  Is there a python command that allows me to extract the names (not values) of the attributes of a class. example Class Sample:     fullname = 'Something' How can I know that this class has an attribute called 'fullname'?

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: What is a class that is not a module? Please stop posting these one-liner beginner questions. If you can type it in one line, you can enter it on the Google.com or Ask.com query page and get a wealth of *existing* information, from tutorials,

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 2:04 pm, [EMAIL PROTECTED] wrote: On Mar 5, 1:29 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Mar 5, 12:50 pm, [EMAIL PROTECTED] wrote: What is a class that is not a module? Please stop posting these one-liner beginner questions.  If you can type it in one line, you can

Re: What is a class?

2008-03-05 Thread Paul McGuire
On Mar 5, 3:49 pm, [EMAIL PROTECTED] wrote: Classes and modules are really similar.  In Python they're really *really* similar. Actually, at this point, that observation may have more of a subjective component than I'm used to asserting.  I pause here for corroboration and others'

Re: Python-based regular expression parser that allows patterns to call functions?

2008-03-02 Thread Paul McGuire
On Mar 2, 8:41 am, Andrew Warkentin [EMAIL PROTECTED] wrote: I am writing a filtering HTTP proxy (the site ishttp://xuproxy.sourceforge.net/). I want it to be compatible with Proxomitron (http://proxomitron.info/) filters. I need a regular expression parser that allows patterns to call

Re: Altering imported modules

2008-03-02 Thread Paul McGuire
On Mar 2, 3:48 pm, Tro [EMAIL PROTECTED] wrote: On Sunday 02 March 2008, Terry Reedy wrote: Tro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Hi, list. | | I've got a simple asyncore-based server. However, I've modified the asyncore | module to allow me to watch

Re: Python-based regular expression parser that allows patterns to call functions?

2008-03-02 Thread Paul McGuire
pyparsing also includes a decorator function, traceParseAction, which will list out calls to parse actions, the tokens passed in, and the value returned or exception raised. If you add @traceParseAction before each of the parse actions in my example, you can see the token processing being done in

Re: Python's BNF

2008-02-29 Thread Paul McGuire
On Feb 29, 7:21 am, [EMAIL PROTECTED] wrote: So, as a nod to the anti-global school of thought, I changed 'ofile' to 'OFILE' so that it would at least look like a global constant. Unfortunately, it's not constant at all. Actually, what you have done is worse. Now you have taken a variable

Re: more pythonic

2008-02-29 Thread Paul McGuire
On Feb 29, 5:57 pm, Alan Isaac [EMAIL PROTECTED] wrote: Paul McGuire wrote: In general, whenever you have:     someNewList = []     for smthg in someSequence:         if condition(smthg):             someNewList.append( elementDerivedFrom(smthg) ) replace it with:     someNewList

Re: more pythonic

2008-02-28 Thread Paul McGuire
On Feb 28, 5:40 am, Temoto [EMAIL PROTECTED] wrote: Hello. There is a Django application, i need to place all its data into Access mdb file and send it to user. It seems to me that params filling for statement could be expressed in a more beautiful way. Since i'm very new to Python, i don't

Re: more pythonic

2008-02-28 Thread Paul McGuire
On Feb 28, 8:58 am, Temoto [EMAIL PROTECTED] wrote: On 28 ÆÅ×, 15:42, Paul McGuire [EMAIL PROTECTED] wrote: On Feb 28, 5:40 am, Temoto [EMAIL PROTECTED] wrote: Hello. There is a Django application, i need to place all its data into Access mdb file and send it to user

Re: is there enough information?

2008-02-26 Thread Paul McGuire
On Feb 26, 8:50 pm, [EMAIL PROTECTED] wrote: Doesn't Queue.Queue operate by side effect? Are you sure you aren't a Turing testbot? What does that question even *mean*? Wait! Don't bother answering, I'm already bored with this thread. I agree with Gabriel. Instead of randomly sprinkling locks

Re: Array of functions, Pythonically

2008-02-25 Thread Paul McGuire
On Feb 25, 11:53 am, [EMAIL PROTECTED] wrote:  { '+': operator.add, '-': operator.sub, ... } Then EXPR OPER EXPR - ops[ OPER ]( EXPR, EXPR ), right? I think this is the most Pythonic idiom. You can even define your own custom binary operators, such as '$' to convert dollars and cents to a

Re: is there enough information?

2008-02-25 Thread Paul McGuire
On Feb 25, 9:30 pm, [EMAIL PROTECTED] wrote: Is it enough? (Reminds me of the movie Marathon Man, in which Dustin Hoffman is repeatedly asked by Laurence Olivier, Is it safe? Hoffman had no idea what Olivier was talking about. So Olivier tortured Hoffman some more to get the answer.) Enough

Re: @synchronized dect'r c.

2008-02-23 Thread Paul McGuire
On Feb 23, 2:03 pm, [EMAIL PROTECTED] wrote: 1) [EMAIL PROTECTED] @synchronized def function( arg ):    behavior() Synchronized prevents usage from more than one caller at once: look up the function in a hash, acquire its lock, and call. def synchronized( func ):    def presynch( *ar,

Re: Simple - looking for a way to do an element exists check..

2008-02-22 Thread Paul McGuire
On Feb 22, 11:20 am, rh0dium [EMAIL PROTECTED] wrote: found = False for item in a:   if item[0] == element[0]     found = True     break if not found:   a.append(element) But this is just ugly - Is there a simpler way to interate over all items in a without using a found flag? Thanks

Re: Simple - looking for a way to do an element exists check..

2008-02-22 Thread Paul McGuire
On Feb 22, 11:20 am, rh0dium [EMAIL PROTECTED] wrote: Hi all, I have a simple list to which I want to append another tuple if element 0 is not found anywhere in the list. element =  ('/smsc/chp/aztec/padlib/5VT.Cat',   '/smsc/chp/aztec/padlib',   '5VT.Cat', (33060)) element1 =  

Re: Simple - looking for a way to do an element exists check..

2008-02-22 Thread Paul McGuire
On Feb 22, 12:54 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Paul Rubin http://[EMAIL PROTECTED] writes:     if any(x==element[0] for x in a):       a.append(element) Should say:      if any(x[0]==element[0] for x in a):         a.append(element) I think you have this backwards.

Re: Simple - looking for a way to do an element exists check..

2008-02-22 Thread Paul McGuire
On Feb 22, 3:38 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Paul McGuire [EMAIL PROTECTED] writes: I think you have this backwards.  Should be:      if not any(x[0]==element[0] for x in a):         a.append(element) I think you are right, it was too early for me to be reading code

Re: using PIL for PCA analysis

2008-02-21 Thread Paul McGuire
On Feb 21, 1:41 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi guys i am trying out  PCA analysis using python.I have a set of jpeg(rgbcolor) images whose pixel data i need to extract and make a matrix .( rows =num of images and cols=num of pixels) For this i need to represent an image as

Re: packing things back to regular expression

2008-02-21 Thread Paul McGuire
On Feb 20, 6:29 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 20 Feb 2008 11:36:20 -0800, Amit Gupta wrote: Before I read the message: I screwed up. Let me write again x = re.compile(CL(?Pname1[a-z]+)) # group name name1 is attached to the match of lowercase

Re: What's the standard for code docs?

2008-02-20 Thread Paul McGuire
On Feb 15, 10:59 am, Preston Landers [EMAIL PROTECTED] wrote: Hey guys and gals.  What are all the cool kids using these days to document their code?  My goal is to create in-line documentation of each package/module/class/method and create some semi-nice looking (or at least usable) packaged

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread Paul McGuire
On Feb 17, 8:09 pm, Christopher Barrington-Leigh [EMAIL PROTECTED] wrote: Here is a file test.csv number,name,description,value 1,wer,tape 2,5 1,vvv,hoohaa,2 I want to convert it to tab-separated without those silly quotes. Note in the second line that a field is 'tape 2' , ie two inches:

Re: Help Parsing an HTML File

2008-02-16 Thread Paul McGuire
On Feb 15, 3:28 pm, [EMAIL PROTECTED] wrote: Hello Python Community, It'd be great if someone could provide guidance or sample code for accomplishing the following: I have a single unicode file that has  descriptions of hundreds of objects. The file fairly resembles HTML-EXAMPLE pasted

Re: regex question

2008-02-13 Thread Paul McGuire
On Feb 13, 6:53 am, mathieu [EMAIL PROTECTED] wrote: I do not understand what is wrong with the following regex expression. I clearly mark that the separator in between group 3 and group 4 should contain at least 2 white space, but group 3 is actually reading 3 +4 Thanks -Mathieu import

Re: Can anyone help, please?

2008-02-12 Thread Paul McGuire
On Feb 12, 4:10 pm, maehhheeyy [EMAIL PROTECTED] wrote: Hi, right now I'm using Python and Multicast. I have the code for Multicast receiver on Python but I keep getting this error; File string, line 1, in bind error: (10049, Can't assign requested address) The error is coming from this

Re: ANN: pyparsing 1.4.11 released

2008-02-11 Thread Paul McGuire
On Feb 11, 3:44 am, [EMAIL PROTECTED] wrote: Maybe you can use the in instead of ==, meaning that a certain string conforms to a certain pattern, that defines an implicit class of possibilities, so with the in you look if the string is present in that class of acceptable patterns, instead of

ANN: pyparsing 1.4.11 released

2008-02-10 Thread Paul McGuire
I have just uploaded version 1.4.11 of pyparsing to SourceForge. It has been a pretty full 2 months since the last release, with contributions from new users, old users, and also some help from the Google Highly-Open Participation contest. I think there are some very interesting new features in

Re: Plotting 3d points

2008-02-10 Thread Paul McGuire
On Feb 10, 4:37 am, Rasmus Kjeldsen [EMAIL PROTECTED] wrote: Anybody know of a simple way to plot 3d points? Nothing fancy, just points. I've tried looking into Mayavi, but can't really find out how to get get 3 arrays (x,y,z) into a vtk file. I've also seen mlab mentioned, but how do I

Re: Reducing types

2008-02-10 Thread Paul McGuire
On Feb 10, 1:19 pm, [EMAIL PROTECTED] wrote: So why not adopt the Decimal (IEEE 854) as the standard float for Python (if speed is a concern, than a mfloat type may be introduced, it's a machine float, it's essentially the float of Python 2.5, operations between a float and a mfloat give a

ANN: pyparsing 1.4.11 released

2008-02-10 Thread Paul McGuire
I have just uploaded version 1.4.11 of pyparsing to SourceForge. It has been a pretty full 2 months since the last release, with contributions from new users, old users, and also some help from the Google Highly-Open Participation contest. I think there are some very interesting new features in

Re: How to identify which numbers in a list are within each others' range

2008-02-08 Thread Paul McGuire
On Jan 31, 10:12 am, erikcw [EMAIL PROTECTED] wrote: Hi, I have a list of numbers each with a +/- margin of error.  I need to identify which ones overlab each other. Here's my proposal, using arithmetic instead of sets. Looking at the problem graphically, I drew different numberlines:

Re: Using Regular Expressions to Parse SQL

2008-02-05 Thread Paul McGuire
On Feb 5, 8:31 am, [EMAIL PROTECTED] wrote: Hello again - I do not seem to be able to get a handle on non-greedy pattern matching. Regexps wont cut it when you have to parse nested ()'s in a logical expression. Here is a pyparsing solution. For your specific application, you will need to

Re: Does anyone else use this little idiom?

2008-02-03 Thread Paul McGuire
On Feb 2, 9:48 pm, Jeff Schwab [EMAIL PROTECTED] wrote: How [EMAIL PROTECTED] wrote: Ruby has a neat little convenience when writing loops where you don't care about the loop index: you just do n.times do { ... some code ... } where n is an integer representing how many times you want to

Re: dict comprehension

2008-02-01 Thread Paul McGuire
On Feb 1, 12:13 am, Paddy [EMAIL PROTECTED] wrote: On Feb 1, 6:06 am, Ryan Ginstrom [EMAIL PROTECTED] wrote: On Behalf Of Daniel Fetchinson What does the author mean here? What's the Preferably One Way (TM) to do something analogous to a dict comprehension? I imagine something like

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Paul McGuire
On Jan 31, 10:43 am, [EMAIL PROTECTED] wrote: Hi, I got some help with this from here, and there's been a little bit of discussion around GA's recently, so thought I'd post up my likey slow and clunky version of a GA that in essence just 'evolves' a solution to 'make a sum that evaluates to

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Paul McGuire
On Feb 1, 9:11 am, [EMAIL PROTECTED] wrote: 0. Tack this bit onto the end of quickga.py, and you wont have to write a separate routine to import quickga and invoke evolve():     if __name__ == __main__:         evolve() I hear you, but something I dont tend to do as I use pythons

Re: very simple Genetic Algorithm completed

2008-02-01 Thread Paul McGuire
On Jan 31, 10:43 am, [EMAIL PROTECTED] wrote: Hi, I got some help with this from here, and there's been a little bit of discussion around GA's recently, so thought I'd post up my likey slow and clunky version of a GA that in essence just 'evolves' a solution to 'make a sum that evaluates to

Re: How to convert markup text to plain text in python?

2008-02-01 Thread Paul McGuire
On Feb 1, 10:54 am, Tim Chase [EMAIL PROTECTED] wrote: Well, if all you want to do is remove everything from a to a , you can use   s = BToday/B is UFriday/U   import re   r = re.compile('[^]*')   print r.sub('', s)   Today is Friday [Tim's ramblings about pathological cases

Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-01-30 Thread Paul McGuire
On Jan 30, 6:40 pm, Blubaugh, David A. [EMAIL PROTECTED] wrote: I do not understand why no one has answered the following question: Has anybody worked with Gene Expression Programming   David Blubaugh Sorry, I was too busy reading the posts about the pubic hair. And did you really wait

Re: Error in parsing XML for following test data

2008-01-29 Thread Paul McGuire
On Jan 29, 4:46 am, Stefan Behnel [EMAIL PROTECTED] wrote: How is this related to XML? Stefan I guess that's what makes so **nasty**! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: py3k feature proposal: field auto-assignment in constructors

2008-01-27 Thread Paul McGuire
On Jan 27, 6:13 pm, Terry Reedy [EMAIL PROTECTED] wrote: I think this version, with this name convention, is nice enough to possibly go in the stdlib if there were an appropriate place for it.  Not sure where though.  If there were a classtools module tjr +1 I thought at one time there

Re: HTML parsing confusion

2008-01-22 Thread Paul McGuire
On Jan 22, 7:44 am, Alnilam [EMAIL PROTECTED] wrote: ...I move from computer to computer regularly, and while all have a recent copy of Python, each has different (or no) extra modules, and I don't always have the luxury of downloading extras. That being said, if there's a simple way of doing

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Paul McGuire
On Jan 22, 7:46 am, Stefan Rank [EMAIL PROTECTED] wrote: I also need to test for generator functions from time to time for which I use::    def _isaGeneratorFunction(func):        '''Check the bitmask of `func` for the magic generator flag.'''        return bool(func.func_code.co_flags

Re: Problem with processing XML

2008-01-22 Thread Paul McGuire
On Jan 22, 8:11 am, John Carlyle-Clarke [EMAIL PROTECTED] wrote: Hi. I'm new to Python and trying to use it to solve a specific problem.  I have an XML file in which I need to locate a specific text node and replace the contents with some other text.  The text in question is actually about

Re: Processing XML that's embedded in HTML

2008-01-22 Thread Paul McGuire
On Jan 22, 10:57 am, Mike Driscoll [EMAIL PROTECTED] wrote: Hi, I need to parse a fairly complex HTML page that has XML embedded in it. I've done parsing before with the xml.dom.minidom module on just plain XML, but I cannot get it to work with this HTML page. The XML looks like this: ...

Re: strange syntax rules on list comprehension conditions

2008-01-18 Thread Paul McGuire
On Jan 18, 1:04 pm, Chris Mellon [EMAIL PROTECTED] wrote: On Jan 18, 2008 12:53 PM, Nicholas [EMAIL PROTECTED] wrote: I was quite delighted today, after extensive searches yielded nothing, to discover how to place an else condition in a list comprehension. Trivial mask example: [True if

Re: next line (data parsing)

2008-01-16 Thread Paul McGuire
On Jan 16, 6:54 pm, [EMAIL PROTECTED] wrote: Hi there, I'm struggling to find a sensible way to process a large chuck of data--line by line, but also having the ability to move to subsequent 'next' lines within a for loop. I was hoping someone would be willing to share some insights to help

Re: split parameter line with quotes

2008-01-11 Thread Paul McGuire
On Jan 11, 12:50 pm, teddyber [EMAIL PROTECTED] wrote: Hello, first i'm a newbie to python (but i searched the Internet i swear). i'm looking for some way to split up a string into a list of pairs 'key=value'. This code should be able to handle this particular example string :

Re: Natural-language datetime parsing and display (was: user friendly datetime features)

2008-01-09 Thread Paul McGuire
On Jan 8, 7:57 pm, Ben Finney [EMAIL PROTECTED] wrote: Daniel Fetchinson [EMAIL PROTECTED] writes: I'm guessing this feature is needed so often in so many projects that it has been implemented already by several people. Does anyone know of such a stand alone module? The 'python-dateutil'

Re: alternating string replace

2008-01-09 Thread Paul McGuire
On Jan 9, 7:41 am, Neil Cerutti [EMAIL PROTECTED] wrote: On Jan 9, 2008 5:34 AM, cesco [EMAIL PROTECTED] wrote: Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the

Re: I'm searching for Python style guidelines

2008-01-07 Thread Paul McGuire
On Jan 7, 12:26 pm, [EMAIL PROTECTED] wrote: Guilherme Polo wrote: foo = [     'too long',     'too long too',     ...     ] OK, I'll put it there too, and it will be easy for us to read each other's code (at least in this particular). While not required by any means, you will also

Re: Open source English dictionary to use programmatically w/ python

2008-01-07 Thread Paul McGuire
On Jan 7, 5:10 pm, dgoldsmith_89 [EMAIL PROTECTED] wrote: Sorry for my ignorance: I can query an Access DB w/ standard SQL queries (and this is how I would access it w/ Python)? DG If you are running on a Mac, just use sqlite, it's built-in to Python as of v2.5 and you will find more help,

Re: how to use bool

2008-01-04 Thread Paul McGuire
On Jan 3, 10:09 am, [EMAIL PROTECTED] wrote: With my philosophical programming hat on the first thing I'd say (as a fairly beginning python programmer) is avoid multiple returns from a function/method if at all possible.  They breed all sorts of problems and errors, in particular if there's

Re: Simple calculation error

2008-01-04 Thread Paul McGuire
On Jan 4, 12:30 pm, Fredrik Lundh [EMAIL PROTECTED] wrote: Francois Liot wrote: I observed a strange calculation answer, on both python 2.3.4 and 2.4.4 print 753343.44 - 753361.89 -18.450001 print ( (753361.89*100) - (753343.44*100) ) / 100 18.45 Can somebody help me to

Re: pyparsing question

2008-01-02 Thread Paul McGuire
On Jan 1, 5:32 pm, hubritic [EMAIL PROTECTED] wrote: I am trying to parse data that looks like this: IDENTIFIER    TIMESTAMP   T  C   RESOURCE_NAME   DESCRIPTION 2BFA76F6     1208230607   T   S   SYSPROC                    SYSTEM SHUTDOWN BY USER A6D1BD62   1215230807     I H                

Re: Is there a string function to trim all non-ascii characters out of a string

2007-12-31 Thread Paul McGuire
On Dec 31, 2:54 am, abhishek [EMAIL PROTECTED] wrote: Use this function -- def omitNonAscii(nstr):     sstr=''     for r in nstr:         if ord(r)127:             sstr+=r     return sstr Yoda Learn the ways of the generator expression you must. /Yoda See Dan Bishop's post. -- Paul --

Re: Python Trajectory Module?

2007-12-31 Thread Paul McGuire
On Dec 31, 9:40 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Greetings, I was wondering if there was a python Module/Library out there that handles some trajectory/physics stuff like moving an object along a straight path in an X,Y 2D (or 3D) plane or calculating parabolic arcs. I'd really

Amusement - rotational palindrome generator

2007-12-20 Thread Paul McGuire
Here is some semi-obfuscated Python, to generate rotational palindromes: from random import choice base = sznuoxpqbdMWOINZXSH rot = dict(zip(base,szunoxdbqpWMOINZXSH)) for i in range(40): s1 = [choice(base) for j in range(choice((2,3,4)))] start = (1,2)[rot[s1[-1]]==s1[-1] and

Re: Another newbie design question

2007-12-19 Thread Paul McGuire
On Dec 19, 10:48 am, [EMAIL PROTECTED] wrote: This morning block comments disappeared from the Decaf design. Maybe later today they'll be instantiated in the tokenizer. Out of the idlest of curiousity, does this language have a BNF, or some other form of grammar definition? -- Paul --

Re: Is there a simple way to parse this string ?

2007-12-19 Thread Paul McGuire
describes here: http://www.effbot.org/zone/simple-iterator-parser.htm. This parser is about 10X faster than the equivalent pyparsing parser. -- Paul (McGuire) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a simple way to parse this string ?

2007-12-19 Thread Paul McGuire
On Dec 19, 4:23 pm, John Machin [EMAIL PROTECTED] wrote: On Dec 20, 9:10 am, Larry Bates [EMAIL PROTECTED] wrote: In particular Paul Maguire recently pointed to a safe evaluator that was restricted (IIRC) to something like lists/dicts/etc of ints/floats/ string/etc constants -- looks like

Re: programming container object

2007-12-17 Thread Paul McGuire
On Dec 17, 1:18 am, bambam [EMAIL PROTECTED] wrote: I wish to create a generic container object, devlist, such that devlist.method(arguments) runs as for each dev in devlist.pool: dev.method(arguments) and s = devlist.method(arguments) runs as for each dev in

Re: programming container object

2007-12-17 Thread Paul McGuire
On Dec 17, 2:31 am, Paul McGuire [EMAIL PROTECTED] wrote: On Dec 17, 1:18 am, bambam [EMAIL PROTECTED] wrote: I wish to create a generic container object, devlist, such that devlist.method(arguments) runs as for each dev in devlist.pool: dev.method(arguments

Re: Finding Line numbers of HTML file

2007-12-13 Thread Paul McGuire
On Dec 13, 9:01 am, Ramdas [EMAIL PROTECTED] wrote: Hi Paul, I am cross posting the same to grab your attention at pyparsing forums too. 1000 apologies on the same count! I am a complete newbie to parsing and totally new to pyparsing. I have adapted your code to store the line numbers as

Stringified list back to list of ints

2007-12-12 Thread Paul McGuire
On Dec 12, 7:25 am, Lee Capps [EMAIL PROTECTED] wrote: Regular expressions might be a good way to handle this. import re s = '[16, 16, 2, 16, 2, 16, 8, 16]' get_numbers = re.compile('\d\d*').findall numbers = [int(x) for x in get_numbers(s)] Isn't '\d\d*' the same as '\d+' ? And why

Re: Pascal code checker!

2007-12-12 Thread Paul McGuire
On Dec 12, 3:03 pm, Tim Chase [EMAIL PROTECTED] wrote: OTOH, you could actually parse the pascal file(s). This gives you infinte flexibility to do whatever you want with the parse-tree. Things get hairy when you have included (uses) files, and you also have to write up a grammar for Pascal

Re: Finding Line numbers of HTML file

2007-12-12 Thread Paul McGuire
On Dec 12, 3:56 pm, Ramdas [EMAIL PROTECTED] wrote: I am doing some HTML scrapping for a side project. I need a method using sgmllib or HTMLParser to parse an HTML file and get line nos of all the tags Homework, perhaps? Well, I don't think your instructor will give many points for a

ANN: pyparsing-1.4.10 released!

2007-12-11 Thread Paul McGuire
I'm happy to announce that I have just uploaded the latest release (v1.4.10) of pyparsing. I had to quick turnaround this release because a bug I thought I had fixed in 1.4.9 still persisted. I now have unit tests to catch the problematic variations in the operatorPrecedence method. This

Counter-spam: Change the subject

2007-12-11 Thread Paul McGuire
On Dec 11, 5:59 am, dfg [EMAIL PROTECTED] wrote: Breakthrough - How To Turn Your Dull Website into Money Making Website snip I was surprised at how effectively the spam posting the other day, Jesus in the Quran was masked and defused by a reply titled J in the Q. It seems this might be a simple

Re: Counter-spam: Change the subject

2007-12-11 Thread Paul McGuire
On Dec 11, 2:28 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Tue, 11 Dec 2007 06:23:43 -0800, Paul McGuire wrote: On Dec 11, 5:59 am, dfg [EMAIL PROTECTED] wrote: Breakthrough - How To Turn Your Dull Website into Money Making Website snip I was surprised at how

Re: abusing exceptions for continuations

2007-12-10 Thread Paul McGuire
On Dec 10, 2:39 am, gangesmaster [EMAIL PROTECTED] wrote: i've had this strange idea of using the exception's traceback (which holds the stack frame) to enable functional continuations, meaning, raise some special exception which will be caught by a reactor/ scheduler/framework, which could

ANN: pyparsing 1.4.10 released!

2007-12-10 Thread Paul McGuire
I'm happy to announce that I have just uploaded the latest release (v1.4.10) of pyparsing. I had to quick turnaround this release because a bug I thought I had fixed in 1.4.9 still persisted. I now have unit tests to catch the problematic variations in the operatorPrecedence method. This

Re: Is a real C-Python possible?

2007-12-09 Thread Paul McGuire
On Dec 9, 6:07 pm, Jack [EMAIL PROTECTED] wrote: Plus, Psyco is not the main stream and has stopped development. scooby-whruu?? What makes you think it has stopped development? I just swung by the SF project page, and its most recent news post was just 2 months ago. Psyco may not be in the

Re: help with pyparsing

2007-12-09 Thread Paul McGuire
On Dec 9, 11:01 pm, Prabhu Gurumurthy [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, I have the following lines that I would like to parse in python using pyparsing, but have some problems forming the grammar. Line in file: table ALINK const {

Re: splitting a words of a line

2007-12-07 Thread Paul McGuire
On Dec 6, 9:21 am, Sumit [EMAIL PROTECTED] wrote: Hi , I am trying to splitt a Line whihc is below of format , AzAccept PLYSSTM01 [23/Sep/2005:16:14:28 -0500] 162.44.245.32 CN= cojack (890),OU=1,OU=Customers,OU=ISM-Users,OU=kkk Secure,DC=customer,DC=rxcorp,DC=com plysmhc03zp

Re: Calculate an age

2007-12-06 Thread Paul McGuire
On Dec 6, 4:19 pm, John Machin [EMAIL PROTECTED] wrote: On Dec 7, 8:34 am, Pierre Quentel [EMAIL PROTECTED] wrote: Hi all, I have searched in the standard distribution if there was a function to return the difference between 2 dates expressed like an age : number of years, of months and

Re: Why did no one tell me about import antigravity?

2007-12-05 Thread Paul McGuire
On Dec 5, 5:12 am, Richard Jones [EMAIL PROTECTED] wrote: Ant wrote: http://xkcd.com/353/ I laughed :) ... I cried, it's a part of me! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Any idea how to open Matlab and run M-files by using Python?

2007-12-03 Thread Paul McGuire
On Dec 2, 10:02 pm, itcecsa [EMAIL PROTECTED] wrote: Hi, I am implementing a small Python project, what I am going to do is to open Matlab and run some M-files, and get some output from Matlab command prompt. I have no idea how to open Matlab from Python! Any suggestions would be

Re: Is __import__ known to be slow in windows?

2007-11-30 Thread Paul McGuire
On Nov 30, 5:08 pm, Joshua Kugler [EMAIL PROTECTED] wrote: [I tried googling for this, didn't find anything relevant.] We've recently been doing some profiling on a project of ours. It runs quite fast on Linux but *really* bogs down on Windows 2003. We initially thought it was the

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 11:32 am, Ryan Krauss [EMAIL PROTECTED] wrote: I need to parse the following string: $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2 }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it

Re: Control mouse position and clicking

2007-11-28 Thread Paul McGuire
On Nov 28, 1:29 pm, Glich [EMAIL PROTECTED] wrote: hi, how can I, control mouse position and clicking from python? I want to interact with a flash application inside firefox. thanks. ps: I am not using windows. Ooof, I was about to suggest using pywinauto, because I was able to interact with

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 1:23 pm, Paul McGuire [EMAIL PROTECTED] wrote: As Tim Grove points out, ... s/Grove/Chase/ Sorry, Tim! -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Paul McGuire
On Nov 26, 10:40 am, lisong [EMAIL PROTECTED] wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect is : 'abc.defg', 'defg.hij', 'hij.klmnop' a simple regular expression

Re: better way to write this function

2007-11-26 Thread Paul McGuire
On Nov 26, 1:42 am, Kelie [EMAIL PROTECTED] wrote: Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what pythonic means yet. def divide_list(lst, n): Divide a list into a number of lists,

Re: How to write Regular Expression for recursive matching?

2007-11-26 Thread Paul McGuire
On Nov 26, 10:51 am, Paul McGuire [EMAIL PROTECTED] wrote: On Nov 26, 10:40 am, lisong [EMAIL PROTECTED] wrote: Hi All, I have problem to split a string like this: 'abc.defg.hij.klmnop' and I want to get all substrings with only one '.' in mid. so the output I expect

Re: can any one tell me where to get graphics module in windows?

2007-11-26 Thread Paul McGuire
On Nov 26, 11:49 pm, evilcraft_mj [EMAIL PROTECTED] wrote: when i type from graphics import * error shown that there is no such module called graphics. help me find this.. Googling for python graphics module turns up this link:

Re: the annoying, verbose self

2007-11-24 Thread Paul McGuire
For these localized initialization blocks, I don't see anything wrong with: _ = self _.var1 = 5 _.var2 = a value _.var3 = stuff _.var4 = [2,54,7,7] _.var5 = dingaling _.var6 = 6.4 _.var7 = 1 _.var8 = False _.var9 = True Or if you wanted to simulate something like using or with: for _ in [self]:

Re: Clean way to get one's network IP address?

2007-11-21 Thread Paul McGuire
On Nov 21, 9:15 am, Gilles Ganault [EMAIL PROTECTED] wrote: Hello I need to get the local computer's IP address, ie. what's displayed when running ifconfig in Linux: # ifconfig eth0 Link encap:Ethernet HWaddr 00:15:58:A1:D5:6F inet addr:192.168.0.79 Bcast:192.168.0.255

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Paul McGuire
On Nov 19, 10:32 am, blaine [EMAIL PROTECTED] wrote: Hey guys, For my Network Security class we are designing a project that will, among other things, implement a Diffie Hellman secret key exchange. The rest of the class is doing Java, while myself and a classmate are using Python (as proof

Re: regular expression

2007-11-19 Thread Paul McGuire
Sorry about your coffee cup! Would you be interested in a pyparsing rendition? -- Paul from pyparsing import * def defineGrammar(): ParserElement.setDefaultWhitespaceChars( \t) ident = Word(alphanums+_) LT,GT = map(Suppress,) NL = LineEnd().suppress() real =

Re: Excellent sci-fi novel featuring Python

2007-11-17 Thread Paul McGuire
On Nov 17, 9:37 am, Wade Leftwich [EMAIL PROTECTED] wrote: I'm about halfway through Charles Stross' excellent new novel, Halting State. It's set in Edinburgh in the year 2018, and one of the main characters is a game programmer whose primary language is something called Python 3000. I should

<    1   2   3   4   5   6   7   8   9   10   >