Re: which Python ? asks beginner

2007-11-17 Thread Paul McGuire
On Nov 17, 12:20 pm, Dave WB3DWE wrote: Have given up Java. Want to switch to Python. But _which_ ? There is ver : 2.5 out now 2.6 in beta , final expected Apr 2008 3.0 ? in alpha or beta 3.0 final expected Sep 2008 ? This is not for us to decide, but rather for

Re: overriding methods - two questions

2007-11-16 Thread Paul McGuire
On Nov 16, 11:03 am, Donn Ingle [EMAIL PROTECTED] wrote: Hi, Here's a framework for the questions: --- In a module, part of an API --- class Basis ( object ): def foo ( self, arg ): pass --- In user's own code --- class Child ( Basis ): def foo ( self, not, sure ): ... Question

Re: Populating a dictionary, fast [SOLVED]

2007-11-13 Thread Paul McGuire
On Nov 12, 11:32 am, Michael Bacarella [EMAIL PROTECTED] wrote: See end for solution. (3) Are you sure you need all eight-million-plus items in the cache all at once? Yes. I remain skeptical, but what do I know, I don't even know what you're doing with the data once you have it

Re: New comer

2007-11-13 Thread Paul McGuire
On Nov 13, 11:37 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, I'm new comer here Welcome to you! Are you new to programming in Python as well, or just new to this newsgroup? If you are new to Python, you will find a wealth of getting started help at the Python web site,

Re: pyparsing and svg

2007-11-08 Thread Paul McGuire
On Nov 8, 3:14 am, Donn Ingle [EMAIL PROTECTED] wrote: float = nums + dot + nums Should be: float = Combine(Word(nums) + dot + Word(nums)) nums is a string that defines the set of numeric digits for composing Word instances. nums is not an expression by itself. For that matter, I see in

Re: How to use list as key of dictionary?

2007-11-06 Thread Paul McGuire
On Nov 6, 4:08 am, Dustan [EMAIL PROTECTED] wrote: On Nov 6, 3:58 am, Duncan Booth [EMAIL PROTECTED] wrote: Wildemar Wildenburger [EMAIL PROTECTED] wrote: maybe something like this could help: def tupleize(non_tuple): try: return tuple(tupleize(thing) for thing in

Re: Please explain collections.defaultdict(lambda: 1)

2007-11-06 Thread Paul McGuire
On Nov 6, 8:54 am, metaperl.com [EMAIL PROTECTED] wrote: I'm readinghttp://norvig.com/spell-correct.html and do not understand the expression listed in the subject which is part of this function: def train(features): model = collections.defaultdict(lambda: 1) for f in features:

Re: regular expressions

2007-11-06 Thread Paul McGuire
On Nov 6, 11:07 am, J. Clifford Dyer [EMAIL PROTECTED] wrote: On Tue, Nov 06, 2007 at 08:49:33AM -0800, [EMAIL PROTECTED] wrote regarding regular expressions: hi i am looking for pattern in regular expreesion that replaces anything starting with and betweeen http:// until /

Re: parsing string to a list of objects - help!

2007-11-05 Thread Paul McGuire
On Nov 5, 3:00 am, Donn Ingle [EMAIL PROTECTED] wrote: I have glanced around at parsing and all the tech-speak confuses the heck out of me. I am not too smart and would appreciate any help that steers away from cold theory and simply hits at this problem. Donn - Here is a pyparsing version

Re: pyparsing frames and tweens - take 2

2007-11-05 Thread Paul McGuire
Donn - The exception you posted is from using an old version of pyparsing. You can get the latest from SourceForge - if you download the Windows binary install, please get the docs package too. It has a full doc directory (generated with epydoc), plus example scripts for a variety of

Re: pyparsing frames and tweens - take 2

2007-11-05 Thread Paul McGuire
Here is a first cut at processing the parsed objects, given a list of Property objects representing the frames at each '#': class Property(object): def __init__(self,**kwargs): self.__dict__.update(kwargs) def copy(self): return Property(**self.__dict__)

Re: instance as a sequence

2007-11-05 Thread Paul McGuire
On Nov 5, 11:32 am, [EMAIL PROTECTED] wrote: suppose i want to make foo.childNodes[bar] available as foo[bar] (while still providing access to the printxml/printprettyxml() functions and other functionality of dom/minidom instance). What is a good way to accomplish that? define

Re: Is pyparsing really a recursive descent parser?

2007-11-03 Thread Paul McGuire
On Nov 3, 12:33 am, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: It has recursion in it but that's not sufficient to call it a recursive descent parser any more than having a recursive implementation of the factorial function. The important part is what it recurses

Re: Is pyparsing really a recursive descent parser?

2007-11-02 Thread Paul McGuire
On Nov 2, 5:47 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: Pyparsing is no recursive descent parser. It doesn't go back in the input stream. The ``OneOrMore(Word(alphas))`` part eats the 'end' and when it can't get more, the parser moves to the ``Literal('end')`` part which fails

Re: ANN: O'Reilly e-book, Getting Started with Pyparsing

2007-11-01 Thread Paul McGuire
On Nov 1, 1:25 am, Paul McGuire [EMAIL PROTECTED] wrote: Several chapter excerpts are available online, including this chapter on the Zen of Pyparsing:http://preview.tinyurl.com/yp4v48 Here is a better link: http://my.safaribooksonline.com/9780596514235/what_makes_pyparsing_so_special -- Paul

ANN: O'Reilly e-book, Getting Started with Pyparsing

2007-10-31 Thread Paul McGuire
details, see O'Reilly's web page: http://www.oreilly.com/catalog/9780596514235/ Thanks, -- Paul McGuire (For those who have downloaded it, please add a review to the book download page.) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation

Re: help with pyparsing

2007-10-31 Thread Paul McGuire
On Oct 31, 6:59 am, Neal Becker [EMAIL PROTECTED] wrote: I'm just trying out pyparsing. I get stack overflow on my first try. Any help? #/usr/bin/python from pyparsing import Word, alphas, QuotedString, OneOrMore, delimitedList first_line = '[' + delimitedList (QuotedString) + ']' def

Re: 3 number and dot..

2007-10-31 Thread Paul McGuire
On Oct 31, 2:58 pm, Abandoned [EMAIL PROTECTED] wrote: Hi.. I want to do this: for examle: 12332321 == 12.332.321 How can i do? x = (12332321,) while (x[0]0): x=divmod(x[0],1000)+x[1:] ... x (0, 12, 332, 321) ..join(map(str,x[1:])) '12.332.321' -- Paul --

ANN: O'Reilly e-book, Getting Started with Pyparsing

2007-10-31 Thread Paul McGuire
details, see O'Reilly's web page: http://www.oreilly.com/catalog/9780596514235/ Thanks, -- Paul McGuire (For those who have downloaded it, please add a review to the book download page.) -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with pyparsing and dealing with null values

2007-10-29 Thread Paul McGuire
On Oct 29, 1:11 am, avidfan [EMAIL PROTECTED] wrote: Help with pyparsing and dealing with null values I am trying to parse a log file (web.out) similar to this: --- MBeanName: mtg-model:Name=mtg-model_managed2,Type=Server

Re: Regular Expression

2007-10-23 Thread Paul McGuire
On Oct 22, 5:29 pm, [EMAIL PROTECTED] wrote: Hi, I'm trying to learn regular expressions, but I am having trouble with this. I want to search a document that has mixed data; however, the last line of every entry has something like C5H4N4O3 or CH5N3.ClH. All of the letters are upper case and

Re: Need help parsing with pyparsing...

2007-10-22 Thread Paul McGuire
On Oct 22, 4:18 am, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: I'm trying to parse with pyparsing but the grammar I'm using is somewhat unorthodox. I need to be able to parse something like the following: UPPER CASE WORDS And Title Like Words ...into two

Re: Need help parsing with pyparsing...

2007-10-22 Thread Paul McGuire
On Oct 22, 4:18 am, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: I'm trying to parse with pyparsing but the grammar I'm using is somewhat unorthodox. I need to be able to parse something like the following: UPPER CASE WORDS And Title Like Words ...into two

Re: Iteration for Factorials

2007-10-22 Thread Paul McGuire
On Oct 22, 8:02 am, vimal [EMAIL PROTECTED] wrote: On Oct 22, 5:43 pm, Marco Mariani [EMAIL PROTECTED] wrote: Py-Fun wrote: def itforfact(n): while n100: print n n+1 n = input(Please enter a number below 100) You function should probably return something.

Re: pyparsing batch file

2007-10-17 Thread Paul McGuire
On Oct 17, 4:47 pm, Fabian Braennstroem [EMAIL PROTECTED] wrote: snip Unfortunately, it does not parse the whole file names with the underscore and I do not know yet, how I can access the line with 'define/boundary-conditions'. Every 'argument' of that command should become a separate python

Re: easy but difficult

2007-10-16 Thread Paul McGuire
On Oct 16, 5:42 am, Francesco Guerrieri [EMAIL PROTECTED] wrote: On 10/16/07, Beema shafreen [EMAIL PROTECTED] wrote: hi everybody, I have a file separated by hash: as shown below, file: A#1 B#2 A#2 A#3 B#3 I need the result like this: A 1#2#3 B 2#3 how will

Re: easy but difficult

2007-10-16 Thread Paul McGuire
On Oct 16, 5:46 am, Amit Khemka [EMAIL PROTECTED] wrote: On 10/16/07, Beema shafreen [EMAIL PROTECTED] wrote: hi everybody, I have a file separated by hash: as shown below, file: A#1 B#2 A#2 A#3 B#3 I need the result like this: A 1#2#3 B 2#3 how will generate

Re: Newbi Q: What is a rational for strings not being lists in Python?

2007-10-16 Thread Paul McGuire
On Oct 15, 3:03 pm, Matt McCredie [EMAIL PROTECTED] wrote: So, the best way to get the posted code to work [...] is to cast the input parameter to a list first. snip s = I am a string x = list(s) x ['I', ' ', 'a', 'm', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g'] .join(x) 'I am a

Re: Simple Text Processing Help

2007-10-15 Thread Paul McGuire
On Oct 14, 8:48 am, [EMAIL PROTECTED] wrote: Hi all, I started Python just a little while ago and I am stuck on something that is really simple, but I just can't figure out. Essentially I need to take a text document with some chemical information in Czech and organize it into another text

Re: Last iteration?

2007-10-14 Thread Paul McGuire
On Oct 12, 5:58 am, Florian Lindner [EMAIL PROTECTED] wrote: Hello, can I determine somehow if the iteration on a list of values is the last iteration? Example: for i in [1, 2, 3]: if last_iteration: print i*i else: print i that would print 1 2 9 Can this be

Re: Last iteration?

2007-10-14 Thread Paul McGuire
On Oct 14, 5:58 am, Paul Hankin [EMAIL PROTECTED] wrote: On Oct 14, 8:00 am, Paul McGuire [EMAIL PROTECTED] wrote: def signal_last(lst): last2 = None it = iter(lst) try: last = it.next() except StopIteration: last = None for last2

Re: matching a street address with regular expressions

2007-10-12 Thread Paul McGuire
On Oct 11, 11:50 pm, John Nagle [EMAIL PROTECTED] wrote: If anyone has a first-rate address parser in Python that will cover most of the developed world, I'd like to talk to them. John Nagle SiteTruth The pyparsing examples

Re: matching a street address with regular expressions

2007-10-12 Thread Paul McGuire
On Oct 12, 8:19 am, John Machin [EMAIL PROTECTED] wrote: ... most of the developed world was the [very optimistic] request. How does it go with JAPAN 112-0001 TOKYO Bunkyo-Ku Hakusan 4-Chome 3- 2 and will it give the same result for 4-3-2 HAKUSAN BUNKYO-KU TOKYO 112-1 JAPAN? OK, a little

Re: matching a street address with regular expressions

2007-10-12 Thread Paul McGuire
On Oct 12, 8:19 am, John Machin [EMAIL PROTECTED] wrote: ... most of the developed world was the [very optimistic] request. How does it go with JAPAN 112-0001 TOKYO Bunkyo-Ku Hakusan 4-Chome 3- 2 and will it give the same result for 4-3-2 HAKUSAN BUNKYO-KU TOKYO 112-1 JAPAN? OK, a little

Re: matching a street address with regular expressions

2007-10-12 Thread Paul McGuire
On Oct 12, 1:07 am, Paul McGuire [EMAIL PROTECTED] wrote: On Oct 11, 11:50 pm, John Nagle [EMAIL PROTECTED] wrote: If anyone has a first-rate address parser in Python that will cover most of the developed world, I'd like to talk to them. John Nagle

ANN: pyparsing 1.4.8 released

2007-10-07 Thread Paul McGuire
I'm happy to announce that I have just uploaded the latest release (v1.4.8) of pyparsing. This release has a few new features and corresponding demonstration examples. There are also a few minor bug-fixes, and a performance speedup in the operatorPrecedence method. Here are the notes: - Added

Re: Problem of Readability of Python

2007-10-07 Thread Paul McGuire
On Oct 7, 1:07 pm, Licheng Fang [EMAIL PROTECTED] wrote: Python is supposed to be readable, but after programming in Python for a while I find my Python programs can be more obfuscated than their C/C ++ counterparts sometimes. Part of the reason is that with heterogeneous lists/tuples at hand,

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Paul McGuire
On Oct 5, 7:52 am, Adrian Cherry [EMAIL PROTECTED] wrote: Steve Holden [EMAIL PROTECTED] wrote innews:[EMAIL PROTECTED]: I've just been told by the editors at Python Magazine that the first issue is out. It's all-electronic so anyone can download and read it. Let them know what you think:

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Paul McGuire
On Oct 5, 9:44 am, Grant Edwards [EMAIL PROTECTED] wrote: On 2007-10-05, Steve Holden [EMAIL PROTECTED] wrote: I've just been told by the editors at Python Magazine that the first issue is out. The first issue is issue number 10? That's a bit silly. -- Grant Edwards

Re: Boolean parser..

2007-10-05 Thread Paul McGuire
On Oct 4, 3:00 pm, [EMAIL PROTECTED] wrote: On Oct 5, 7:29 am, Abandoned [EMAIL PROTECTED] wrote: Hi.. I try a boolean parser in python since 1 weak.. But i can't do this because this is very complicated :( Do you know any blooean parser script in python or how do i write a boolean

Re: Boolean parser..

2007-10-05 Thread Paul McGuire
On Oct 5, 7:00 am, Abandoned [EMAIL PROTECTED] wrote: http://pyparsing.wikispaces.com/space/showimage/searchparser.pythis is searchparser but i can't understant to use this. Can anybody explain this how to use ? The code demonstrates a testing example, named TestParser, which inherits from

Re: List Question

2007-10-02 Thread Paul McGuire
On Oct 2, 4:20 pm, Paul Hankin [EMAIL PROTECTED] wrote: On Oct 2, 10:06 pm, brad [EMAIL PROTECTED] wrote: How is this expressed in Python? If x is in y more than three times: print x y is a Python list. Simple and readable: if len([a for a in y if x == a]) 3: print x Or

Re: List Question

2007-10-02 Thread Paul McGuire
On Oct 2, 4:58 pm, Pablo Ziliani [EMAIL PROTECTED] wrote: Paul Hankin wrote: On Oct 2, 10:06 pm, brad [EMAIL PROTECTED] wrote: How is this expressed in Python? If x is in y more than three times: print x y is a Python list. Simple and readable: if len([a for a in y if x ==

Re: Create a string array of all comments in a html file...

2007-09-30 Thread Paul McGuire
On Sep 30, 10:39 am, sophie_newbie [EMAIL PROTECTED] wrote: Hi, I'm wondering how i'd go about extracting a string array of all comments in a HTML file, HTML comments obviously taking the format !-- Comment text here --. I'm fairly stumped on how to do this? Maybe using regular expressions?

Re: Using closures and partial functions to eliminate redundant code

2007-09-26 Thread Paul McGuire
On Sep 26, 9:01 pm, Matthew Wilson [EMAIL PROTECTED] wrote: I wrote some code to create a user and update a user on a remote box by sending emails to that remote box. When I was done, I realized that my create_user function and my update_user function were effectively identical except for

Re: Regular Expressions: Can't quite figure this problem out

2007-09-25 Thread Paul McGuire
On Sep 24, 11:23 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 24 Sep 2007 23:51:57 -0300, Robert Dailey [EMAIL PROTECTED] escribi?: What I meant was that it's not an option because I'm trying to learn regular expressions. RE is just as built in as anything else. Ok, let's

Re: Nested For and While Statements

2007-09-24 Thread Paul McGuire
On Sep 24, 2:28 pm, [EMAIL PROTECTED] wrote: I start my code with some constants then a while statement. But I have some For statements towards the end within the While statement where I start getting some errors. I'm hoping I won't have to post my code, but it looks something like this:

Re: compile for ARM

2007-09-19 Thread Paul McGuire
On Sep 19, 12:41 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Rafael Marin Perez schrieb: Hello I'm Rafael Marin, and work as reseacher in University of Murcia (Spain). I want to install and compile modules of python2.4 in a ARMv5b architecture. Any idea? You might consider

Re: Cannot formulate regex

2007-09-16 Thread Paul McGuire
On Sep 16, 10:18 am, Dotan Cohen [EMAIL PROTECTED] wrote: I'd like to filter spam from a certain company. Here are examples of strings found in their spam: Mega Dik Mega D1k MegaDik Mega. Dik M eg ad ik M E _G_A_D_ IK M_E_G. ADI. K I figured that this regex would match all but the

Re: Cannot formulate regex

2007-09-16 Thread Paul McGuire
On Sep 16, 10:18 am, Dotan Cohen [EMAIL PROTECTED] wrote: I'd like to filter spam from a certain company. Here are examples of strings found in their spam: Mega Dik Mega D1k MegaDik Mega. Dik M eg ad ik M E _G_A_D_ IK M_E_G. ADI. K I figured that this regex would match all but the

Re: extract text from log file using re

2007-09-14 Thread Paul McGuire
On Sep 13, 4:09 pm, Fabian Braennstroem [EMAIL PROTECTED] wrote: Hi, I would like to delete a region on a log file which has this kind of structure: How about just searching for what you want. Here are two approaches, one using pyparsing, one using the batteries-included re module. -- Paul

Re: plotting pixels in python

2007-09-13 Thread Paul McGuire
On Sep 13, 1:03 pm, [EMAIL PROTECTED] wrote: hi to all I am just a beginner of python. I want to know how pixels are plotted in python. I am not intending to use PIL because I don't need to manipulate images. So is there a simple module for 2D graphics and plot pixels Here is a *very*

Re: plotting pixels in python

2007-09-13 Thread Paul McGuire
On Sep 13, 1:37 pm, [EMAIL PROTECTED] wrote: On Sep 13, 11:22 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Sep 13, 1:03 pm, [EMAIL PROTECTED] wrote: hi to all I am just a beginner of python. I want to know how pixels are plotted in python. I am not intending to use PIL because I

Re: How to Start

2007-09-13 Thread Paul McGuire
On Sep 13, 4:59 pm, [EMAIL PROTECTED] (Michael R. Copeland) wrote: Yes, I could fire up the interactive mode and play with some statements...but I consider that sort of thing for programming neophytes or experimenting with specific issues. To misquote Francis Bacon, you would have fish,

Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()

2007-09-12 Thread Paul McGuire
On Sep 11, 1:12 pm, Steve [EMAIL PROTECTED] wrote: Hi All (especially Paul McGuire!) Could you lend a hand in the grammar and paring of the output from the function win32pdhutil.ShowAllProcesses()? This is the code that I have so far (it is very clumsy at the moment) : snip Many thanks

Re: Parsing nested constructs

2007-09-08 Thread Paul McGuire
On Sep 8, 3:42 pm, tool69 [EMAIL PROTECTED] wrote: Hi, I need to parse some source with nested parenthesis, like this : cut- { {item1} { {item2} {item3} } } cut- In fact I'd like to get all start indexes of items and their end

Re: Parsing nested constructs

2007-09-08 Thread Paul McGuire
On Sep 8, 10:01 pm, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Again pyparsing to the rescue :) I have to do a parsing project in Java right now and I dearly miss pyparsing. I explained it to the guy I'm working for, and he was pretty impressed. Thought that might make you smile. /W

Re: creating really big lists

2007-09-06 Thread Paul McGuire
On Sep 6, 12:47 am, Dr Mephesto [EMAIL PROTECTED] wrote: I need some real speed! a database is waaay to slow for the algorithm im using. and because the sublists are of varying size, i dont think I can use an array...- Hide quoted text - - Show quoted text - How about a defaultdict

Re: HowTo Use Cython on a Windows XP Box?

2007-09-01 Thread Paul McGuire
On Sep 1, 12:13 am, John Machin [EMAIL PROTECTED] wrote: On Sep 1, 1:40 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Aug 31, 9:06 pm, David Lees [EMAIL PROTECTED] wrote: August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py

Re: HowTo Use Cython on a Windows XP Box?

2007-08-31 Thread Paul McGuire
On Aug 31, 9:06 pm, David Lees [EMAIL PROTECTED] wrote: August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py translator on the demo code. But when I try compiling, I get an error complaining that my version of Python (which is the current

Re: Python molecular viewer

2007-08-30 Thread Paul McGuire
On Aug 29, 8:31 am, Andy Cheesman [EMAIL PROTECTED] wrote: Dear People, I was wondering if people could recommend a simple molecular viewing package written in python. I'm working in Theoretical chemistry and I'm not after an all-singing dancing molecular rendering package(pymol does that

Re: Important Research Project

2007-08-30 Thread Paul McGuire
On Aug 30, 8:12 am, E.D.G. [EMAIL PROTECTED] wrote: Important Research Project (Related to computer programming) Posted by E.D.G. on August 30, 2007 [EMAIL PROTECTED] This report is being posted to a number of Internet Newsgroups Always the hallmark of a considerate poster. to see if

Re: Newbie question - sorting a slice

2007-08-28 Thread Paul McGuire
On Aug 28, 9:43 pm, hwg [EMAIL PROTECTED] wrote: I've searched the group and didn't see the answer to this... Why doesn't this work?: letters = ['d', 'a', 'e', 'c', 'b'] letters[1:3].sort() This returns None. Why? letters[1:3] is ['a', 'e', 'c']Sorting that should return ['a',

Re: Parser Generator?

2007-08-27 Thread Paul McGuire
On Aug 26, 10:48 pm, Steven Bethard [EMAIL PROTECTED] wrote: Paul McGuire wrote: On Aug 26, 8:05 pm, Ryan Ginstrom [EMAIL PROTECTED] wrote: The only caveat being that since Chinese and Japanese scripts don't typically delimit words with spaces, I think you'd have to pass the text through

Re: convert non-delimited to delimited

2007-08-27 Thread Paul McGuire
assistance is greatly appreaciated! Using Python 2.4 I'm guessing that these lines *aren't* fixed-length, especially those signed integer fields. I used the patented Paul McGuire CrystalBall module to come up with this pyparsing rendition. (OP may adjust to suit.) -- Paul data

Re: Parser Generator?

2007-08-26 Thread Paul McGuire
On Aug 26, 8:05 pm, Ryan Ginstrom [EMAIL PROTECTED] wrote: On Behalf Of Jason Evans Parsers typically deal with tokens rather than individual characters, so the scanner that creates the tokens is the main thing that Unicode matters to. I have written Unicode-aware scanners for use with

Re: beginner, idiomatic python

2007-08-25 Thread Paul McGuire
On Aug 23, 11:50 pm, bambam [EMAIL PROTECTED] wrote: Thank you, so generallizing: (1) Python re-evaluates the loop range on every loop, and (2) Python does short-circuit evaluation of conditions, in predictable order. Sorry about the bad question. A beginner would do well to work through

Re: Joining Big Files

2007-08-25 Thread Paul McGuire
On Aug 25, 4:57 am, mosscliffe [EMAIL PROTECTED] wrote: I have 4 text files each approx 50mb. yawn 50mb? Really? Did you actually try this and find out it was a problem? Try this: import time start = time.clock() outname = temp.dat outfile = file(outname,w) for inname in ['file1.dat',

Re: Joining Big Files

2007-08-25 Thread Paul McGuire
On Aug 25, 8:15 pm, Paul McGuire [EMAIL PROTECTED] wrote: On Aug 25, 4:57 am, mosscliffe [EMAIL PROTECTED] wrote: I have 4 text files each approx 50mb. yawn 50mb? Really? Did you actually try this and find out it was a problem? Try this: import time start = time.clock() outname

Re: Parser Generator?

2007-08-24 Thread Paul McGuire
On Aug 18, 11:37 pm, Jack [EMAIL PROTECTED] wrote: Thanks for all the replies! SPARK looks promising. Its doc doesn't say if it handles unicode (CJK in particular) encoding though. Yapps also looks powerful:http://theory.stanford.edu/~amitp/yapps/ There's also

Re: Eval and raw string ??

2007-08-22 Thread Paul McGuire
On Aug 22, 11:06 am, Mark [EMAIL PROTECTED] wrote: Eval() doesn't seem to recognize the r'string' format. Is there a way around this. Example: If I input: - eval(r'C:\tklll\ndfd\bll') I get the output: Traceback (most recent call last): File pyshell#3, line 1, in module

Re: Newbee Question

2007-08-20 Thread Paul McGuire
On Aug 20, 9:23 am, HD1956 [EMAIL PROTECTED] wrote: This is probably a simple code. I am a truck driver who gets paid by stops and cases. I am trying to figure out how to code my stop pay. I get 40 cents per stop up to 22 stops, and $1.40 per stops after that. You'll get top marks for turning

Re: regular expression dictionary search

2007-08-20 Thread Paul McGuire
On Aug 20, 10:35 am, Shawn Milochik [EMAIL PROTECTED] wrote: #!/usr/bin/env python snip if __name__ == __main__: print The return for 'fred' : %s % returnCode('fred') print The return for 'silk' : %s % returnCode('silk') print The return for 'silky' : %s % returnCode('silky')

Re: Python on Computation, Math and Statistics

2007-08-19 Thread Paul McGuire
On Aug 19, 2:32 pm, W. Watson [EMAIL PROTECTED] wrote: Google? What's that? Thanks. I like to get a insider's view when I know experts are out there. FYI the insiders and experts out there appreciate knowing that you did a little work on your own before just posting questions. I like to get a

Re: Naming dictionaries recursively

2007-08-17 Thread Paul McGuire
On Aug 17, 7:38 am, TYR [EMAIL PROTECTED] wrote: I'd like to do something like this; iterate through a file which consists of data stored in dictionary format, one dict on each line, and read each line into a new dict using one of the values in the dict as its name... for example: stuff =

Re: Problem using Optional pyparsing

2007-08-16 Thread Paul McGuire
On Aug 16, 2:09 am, Nathan Harmston [EMAIL PROTECTED] wrote: Hi, I know this isnt the pyparsing list, but it doesnt seem like there is one. I m trying to use pyparsing to parse a file however I cant get the Optional keyword to work. snip Thanks, Peter, your comments are dead-on.

Re: How to say $a=$b-{A} ||={} in Python?

2007-08-16 Thread Paul McGuire
On Aug 16, 8:28 pm, Jonathan Gardner [EMAIL PROTECTED] wrote: On Aug 16, 3:35 pm, beginner [EMAIL PROTECTED] wrote: In perl it is just one line: $a=$b-{A} ||={}. a = b.setdefault('A', {}) This combines all two actions together: - Sets b['A'] to {} if it is not already defined - Assigns

Re: How to say $a=$b-{A} ||={} in Python?

2007-08-16 Thread Paul McGuire
On Aug 16, 6:03 pm, Carl Banks [EMAIL PROTECTED] wrote: On Aug 16, 6:35 pm, beginner [EMAIL PROTECTED] wrote: Hi All. I'd like to do the following in more succint code: if k in b: a=b[k] else: a={} b[k]=a a['A']=1 In perl it is just one line: $a=$b-{A} ||={}.

Re: How to say $a=$b-{A} ||={} in Python?

2007-08-16 Thread Paul McGuire
On Aug 16, 7:53 pm, beginner [EMAIL PROTECTED] wrote: On Aug 16, 6:21 pm, James Stroud [EMAIL PROTECTED] wrote: beginner wrote: Hi All. I'd like to do the following in more succint code: if k in b: a=b[k] else: a={} b[k]=a a['A']=1 In perl it is

defaultdict of arbitrary depth

2007-08-16 Thread Paul McGuire
In responding to another post on defaultdict, I posted an implementation of a 2-level hashtable, by creating a factory method that returned a defaultdict(dict). The OP of that other thread was trying to build a nested tree from a set of n-tuples, in which the first (n-1) values in each tuple were

Re: defaultdict of arbitrary depth

2007-08-16 Thread Paul McGuire
On Aug 16, 11:19 pm, Carsten Haese [EMAIL PROTECTED] wrote: On Thu, 2007-08-16 at 20:25 -0700, Paul McGuire wrote: [...] I've hacked out this recursivedefaultdict which is a defaultdict(defaultdict(defaultdict(...))), arbitrarily deep depending on the keys provided in the reference

Re: Retry: Question about FutureWarning

2007-08-15 Thread Paul McGuire
On Aug 14, 8:49 pm, Erik Max Francis [EMAIL PROTECTED] wrote: Steven W. Orr wrote: M1.py:268: FutureWarning: hex/oct constants sys.maxint will return positive values in Python 2.4 and up StartTime = safe_dict_get ( dic, 'starttime', 0x ) ... import warnings

Re: replacement for string.printable

2007-08-15 Thread Paul McGuire
On Aug 15, 1:56 pm, John K Masters [EMAIL PROTECTED] wrote: From what I have read the string module is obsolete and should not be used but I am working on a project that parses printable files created in a DOS program and creates a web page for each file. I am using the string.printable

Python in Chinese

2007-08-13 Thread Paul McGuire
Back in May, there was quite an extensive discussion of whether or not Python should support Unicode identifiers (with the final result being that this would be supported in Python 3). In my periodic googling for pyparsing users, I stumbled upon Zhpy, a preprocessor that renders on the fly

Re: Regular Expression Grouping

2007-08-12 Thread Paul McGuire
On Aug 12, 12:21 pm, [EMAIL PROTECTED] wrote: I cannot understand why 'c' constitutes a group here without being surrounded by ( ,) ? import re m = re.match(([abc])+, abc) m.groups() ('c',) It sounds from the other replies that this is just the way re's work - if a group is

Re: step through .py file in a .NET application written in C# in Visual Studio

2007-08-07 Thread Paul McGuire
On Aug 6, 5:22 pm, Bo [EMAIL PROTECTED] wrote: Hello All, I am experimenting IronPython in Visual Studio. Here is what I have, what I did and what I want 1. I have installed Visual Studio SDK 4.0 according to this

Re: parsing a dbIII file

2007-08-07 Thread Paul McGuire
On Aug 7, 2:21 am, Steve Holden [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hello everybody, I'm new to python (...I work with cobol...) I have to parse a file (that is a dbIII file) whose stucture look like this: |string|, |string|, |string that may contain commas inside|, 1, 2,

Re: Extending Python by Adding Keywords Data types

2007-08-01 Thread Paul McGuire
On Jul 31, 3:28 pm, Maximus Decimus [EMAIL PROTECTED] wrote: I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced python developers. II want to add some more

Re: access the name of my method inside it

2007-08-01 Thread Paul McGuire
On Aug 1, 8:07 am, james_027 [EMAIL PROTECTED] wrote: Hi, On Aug 1, 5:18 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 01 Aug 2007 09:06:42 +, james_027 wrote: for example I have this method def my_method(): # do something # how do I get the name of

Re: Buffering HTML as HTMLParser reads it?

2007-08-01 Thread Paul McGuire
On Aug 1, 1:31 pm, [EMAIL PROTECTED] wrote: snip I'm thinking maybe somehow have HTMLParser append each character it reads except for data inside tags in some kind of buffer? This way I can have the HTML contents read into a buffer, then when I do my own handle_ overrides, I can also append

Re: Extending Python by Adding Keywords Data types

2007-08-01 Thread Paul McGuire
On Aug 1, 3:10 pm, Maximus Decimus [EMAIL PROTECTED] wrote: Your code snippet was quite simple and it explained me very well than the tutorial. HAts off to u!! Thanks! snip I am doing my research in Pervasive space environments filled with sensors and actuators. I am just trying to modify

Re: frequency analysis of a DB column

2007-08-01 Thread Paul McGuire
On Aug 1, 9:21 pm, goldtech [EMAIL PROTECTED] wrote: In Python 2.1 are there any tools to take a column from a DB and do a frequency analysis - a breakdown of the values for this column? Possibly a histogram or a table saying out of 500 records I have one hundred and two 301 ninety-eight 212

Re: Extending Python by Adding Keywords Data types

2007-08-01 Thread Paul McGuire
On Aug 1, 8:08 am, Paul McGuire [EMAIL PROTECTED] wrote: def add(self,other): if len(self.contents) self.capacity: self.contents.append( other ) else: raise ValueError(can't add any more to this Box) I guess that really should raise

Re: split a string of space separated substrings - elegant solution?

2007-07-31 Thread Paul McGuire
On Jul 31, 3:30 pm, Helmut Jarausch [EMAIL PROTECTED] wrote: I'm looking for an elegant solution to the following (quite common) problem: Given a string of substrings separated by white space, split this into tuple/list of elements. The problem are quoted substrings like abc xy z 1 2 3 a

Re: pyparser and recursion problem

2007-07-27 Thread Paul McGuire
On Jul 26, 10:40 pm, [EMAIL PROTECTED] wrote: Hey, Thanks Neil and Paul! After reading Neil's advice I started playing around with the setParseAction method, and then I found Paul's script 'macroExpander.py' (http://pyparsing.wikispaces.com/space/showimage/ macroExpander.py). snip Great!

Re: vs !=

2007-07-27 Thread Paul McGuire
On Jul 27, 7:35 am, Neil Cerutti [EMAIL PROTECTED] wrote: I like 'not ==', cf 'not in'. Sadly it's a syntax error. However, as a language designer, I'm not Guido. I'd settle for == Guido myself. :) -- Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: pyparser and recursion problem

2007-07-26 Thread Paul McGuire
On Jul 26, 3:27 pm, Neil Cerutti [EMAIL PROTECTED] wrote: Hopefully I'll have time to help you a bit more later, or Paul MaGuire will swoop down in his pyparsing powered super-suit. ;) There's no need to fear...! Neil was dead on, and your parser is almost exactly right. Congratulations for

Re: Can a low-level programmer learn OOP?

2007-07-23 Thread Paul McGuire
On Jul 23, 5:53 am, [EMAIL PROTECTED] (Eddie Corns) wrote: Wolfgang Strobl [EMAIL PROTECTED] writes: few of James Gimple's snippets from Algorithms in SNOBOL4 (-http://www.snobol4.org/) as an exercise using that library might help to get a better appreciation. Perhaps I'll try, eventually ...

Re: Can a low-level programmer learn OOP?

2007-07-23 Thread Paul McGuire
On Jul 23, 12:43 pm, [EMAIL PROTECTED] (Eddie Corns) wrote: Paul McGuire [EMAIL PROTECTED] writes: On Jul 23, 5:53 am, [EMAIL PROTECTED] (Eddie Corns) wrote: Wolfgang Strobl [EMAIL PROTECTED] writes: few of James Gimple's snippets from Algorithms in SNOBOL4 (-http://www.snobol4.org

ANN: pyparsing1.4.7

2007-07-22 Thread Paul McGuire
I just uploaded the latest release (v1.4.7) of pyparsing, and I'm happy to say, it is not a very big release - this module is getting to be quite stable. A few bug-fixes, and one significant notation enhancement: setResultsNames gains a big shortcut in this release (see below). No new examples

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