Re: Mining strings from a HTML document.

2006-01-26 Thread Derick van Niekerk
I'm battling to understand this. I am switching to python while in a production environment so I am tossed into the deep end. Python seems easier to learn than other languages, but some of the conventions still trip me up. Thanks for the link - I'll have to go through all the previous chapters to

Re: Best way to extract an item from a set of len 1

2006-01-26 Thread Peter Otten
Alex Martelli wrote: Rene Pijlman [EMAIL PROTECTED] wrote: Peter Otten: s = set([one-and-only]) item, = s ... The comma may easily be missed, though. You could write: (item,) = s But I'm not sure if this introduces additional overhead. Naah...: helen:~ alex$ python

Re: Problem compiling Tkinter program with bmp images using py2

2006-01-26 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: and put them on the widgets like this: Label(win, text=message, background=rgb(150,150,120), image=photo2).pack() ... Now, I want the same program to run as exe file on another computer, so I compiled it with py2exe. I copied the bmp's to the same folder as my

Assigning to self.__class__

2006-01-26 Thread Paul McGuire
I have some places in pyparsing where I've found that the most straightforward way to adjust an instance's behavior is to change its class. I do this by assigning to self.__class__, and things all work fine. (Converting to use of __new__ is not an option - in one case, the change is temporary,

Re: Assigning to self.__class__

2006-01-26 Thread bruno at modulix
Paul McGuire wrote: I have some places in pyparsing where I've found that the most straightforward way to adjust an instance's behavior is to change its class. Hooray ! You've just (re)discovered the state pattern... for which the most stupid simple implementation in Python is to : (snip)

Re: ImportError: No module name MySQLdb

2006-01-26 Thread bruno at modulix
Fred wrote: I hope someone can help me with the below problem... Thanks, Fred My enviroment: -- Slackware Linux 10.2 Python 2.4.2 MySql version 4.1.14 MySql-Python 1.2.0 What I am trying to do: --- Using MySQL, Python, My-Sql-Python

Re: Assigning to self.__class__

2006-01-26 Thread Heiko Wundram
bruno at modulix wrote: Paul McGuire wrote: or am I taking advantage of a fortuitous accident, which may get undone at a future time? It's certainly not a fortuitous accident. And even the (printed) cookbook has examples which assign to self.__class__... I guess this means this feature

history

2006-01-26 Thread yqyq22
Dear all, another little question, I use idle 1.1.2, is there a way to use a history for the command line? thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Re: good library for pdf

2006-01-26 Thread Rob Cowie
Take a look at www.reportlab.org. The ReportLab library includes a graphics module that might well do what you need. I'm not sure at present if it allows one to set alpha-channels to achieve transparency. Also, if you have access to a mac running OS X 10.4, the Automator application has a

good library for pdf

2006-01-26 Thread Enrique Palomo Jiménez
Hi all, I want to take an existing pdf and add it a non-opaque watermark. I have tried it in postscript but postscript hava an opaque imaging model. Pdf allows it. I can do it with acrobat 6.0, but i need to add the watermark in batch mode or inside an application. I've found lowagie library

Re: Mining strings from a HTML document.

2006-01-26 Thread Derick van Niekerk
Runsun Pan helped me out with the following: You can also try the following very primitive solution that I sometimes use to extract simple information in a quick and dirty way: def extract(text,s1,s2): ''' Extract strings wrapped between s1 and s2. t=this is a

Re: good library for pdf

2006-01-26 Thread Robin Becker
Rob Cowie wrote: Take a look at www.reportlab.org. The ReportLab library includes a graphics module that might well do what you need. I'm not sure at present if it allows one to set alpha-channels to achieve transparency. ReportLab allows one to set a transparent image colour mask which is

Re: How to handle two-level option processing with optparse

2006-01-26 Thread Steve Holden
R. Bernstein wrote: Giovanni Bajo suggests: If you call OptionParser.disable_interspersed_args() on your parser, it will stop parsing at the first positional argument, leaving other options unparsed. Wow - that was a quick answer! Thanks - it works great! I see how I missed this.

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Steve Holden
Fred wrote: I hope someone can help me with the below problem... Thanks, Fred My enviroment: -- Slackware Linux 10.2 Python 2.4.2 MySql version 4.1.14 MySql-Python 1.2.0 What I am trying to do: --- Using MySQL, Python, My-Sql-Python

While loop - print several times but on 1 line.

2006-01-26 Thread Danny
Hello there. I'm creating a little text changer in Python. In the program there is a while loop. The problem is that a while loop will have 1 print statement and it will loop until it gets to the end of the text. Example: num = 5 // Set num to 5 while num = 1: // loop 5 times. print

Re: Python code written in 1998, how to improve/change it?

2006-01-26 Thread Bengt Richter
On Wed, 25 Jan 2006 15:50:27 -0600, [EMAIL PROTECTED] wrote: If they need to resume their calculations from where they left off after the last yield. Wolfgang Well, no, independently from that. Wolfgang Just to avoid to inital overhead of the function call. How do you pass

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Diez B. Roggisch
Danny wrote: Hello there. I'm creating a little text changer in Python. In the program there is a while loop. The problem is that a while loop will have 1 print statement and it will loop until it gets to the end of the text. Example: num = 5 // Set num to 5 while num = 1: // loop 5

Re: good library for pdf

2006-01-26 Thread Steve Holden
Enrique Palomo Jiménez wrote: Hi all, I want to take an existing pdf and add it a non-opaque watermark. I have tried it in postscript but postscript hava an opaque imaging model. Pdf allows it. I can do it with acrobat 6.0, but i need to add the watermark in batch mode or inside an

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Heiko Wundram
Danny wrote: snip As a shortcut: print text*5 --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible memory leak?

2006-01-26 Thread Fredrik Lundh
Steven D'Aprano wrote: Of course. I was just trying to make a point about string accumulation being O(n) and not O(n^2). But according to Fredrik, string accumulation is still quadratic, even with the optimizations added to Python 2.4. Quoting: it only means that if the interpreter can

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Stefan Neumann
Danny wrote: How could I make this print: texttexttexttexttext? Ive researched and looked through google and so far I can't find anything that will help (or revelent for that matter). I am not quite sure, if I simplify the problem but i thought about something like that: print

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
I think I should paste some of the programs code a little more of what I want... var = 0 while var = 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). I'm just trying to make the value of a[t[var]] print on one

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Claudio Grondi
Danny wrote: I think I should paste some of the programs code a little more of what I want... var = 0 while var = 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). I'm just trying to make the value of

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
Great! It's been solved. The line, as Glaudio said has a , at the end and that makes it go onto one line, thanks so much man! var = 0 while = 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: I think I should paste some of the programs code a little more of what I want... var = 0 while var = 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). I'm just trying to make the value of

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: Great! It's been solved. The line, as Glaudio said has a , at the end and that makes it go onto one line, thanks so much man! var = 0 while = 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. if you wanted spaces between the items, why didn't

Re: ZODB and Zope on one Linux machine, how?

2006-01-26 Thread Rene Pijlman
Terry Hancock: Rene Pijlman: Option 1: Install ZODB in the Python installation in the usual way. Should I expect problems when I install and run zope with that Python installation? I think this should work, actually. ZODB is just like other databases in that each application is going to

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Sion Arrowsmith
Danny [EMAIL PROTECTED] wrote: The programs output will be: text text (etc) How could I make this print: texttexttexttexttext? Ive researched and looked through google and so far I can't find anything that will help (or revelent for that matter). I'm kind of surprised this isn't a FAQ (if it's

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Jeffrey Schwab
Danny wrote: Great! It's been solved. The line, as Glaudio said has a , at the end and that makes it go onto one line, thanks so much man! var = 0 while = 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. Looping over indexes is kinda unpythonic in its

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Danny wrote: I think I should paste some of the programs code a little more of what I want... probably... var = 0 while var = 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). It might be important... I'm

Re: Converting date to milliseconds since 1-1-70

2006-01-26 Thread Xavier Morel
NateM wrote: Thank you! If I am reading in dates as strings from a text file, like 5/11/1998, how do I convert that to a format I can pass into mktime? Thanks again. Check time.strptime() -- http://mail.python.org/mailman/listinfo/python-list

en la misma linea

2006-01-26 Thread Sebastian Bassi
Hola, Aca con una pregunta basica: A veces veo que hay programas que tienen varias instrucciones en la misma linea, cuando lo que aprendi de Python era que se usaba el espaciado para mantener la estructura (indent). Por ejemplo: if name != 'comic': return Hay un return despues de los dos puntos,

isplit

2006-01-26 Thread bearophileHUGS
I have a file of lines that contains some extraneous chars, this the basic version of code to process it: IDtable = .join(map(chr, xrange(256))) text = file(..., rb).read().translate(IDtable, toRemove) for raw_line in file(file_name): line = raw_line.translate(IDtable, toRemove) ... A

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
Re-reading my message I noticed a stupid error, not effecting my problem but annoying, I assigned variables and then did not use them, then included import cgi for my regular script. This is how the command line script should look: #!/usr/bin/python import MySQLdb db=MySQLdb.connect(host =

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Jeffrey Schwab wrote: Danny wrote: Great! It's been solved. The line, as Glaudio said has a , at the end and that makes it go onto one line, thanks so much man! var = 0 while = 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. Looping over indexes

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
This is the result of print sys.path: print sys.path ['', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4', '/usr/local/lib/python2.4/plat-linux2', '/usr/local/lib/python2.4/lib-tk', '/usr/local/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/site-packages'] MySQLdb lives here

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
Here is the complete error from my Apache error log: Traceback (most recent call last): File /var/www/cgi-bin/mysqld_script_test.py, line 7, in ? import MySQLdb ImportError: No module named MySQLdb [Thu Jan 26 07:25:16 2006] [error] [client 127.0.0.1] malformed header from script. Bad

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
From what I can tell everything seems right. Here are the results of the sys.path: print sys.path ['', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4', '/usr/local/lib/python2.4/plat-linux2', '/usr/local/lib/python2.4/lib-tk', '/usr/local/lib/python2.4/lib-dynload',

Nitpicking - slightly misleading traceback

2006-01-26 Thread Juho Schultz
if ((data[x][y] 0) or (datadict.has_key[key])): Traceback (most recent call last): File reduce.py, line 524, in remove_badvalues if ((data[x][y] 0) or TypeError: unsubscriptable object However, the bug sits on the next line. I used square brackets when normal brackets were needed

Re: Convert a long XML string into indented format

2006-01-26 Thread Paul Boddie
Jim wrote: You want to pretty print. Have a look at http://www.boddie.org.uk/python/XML_intro.html for example. Thank you to Paul, I've found that page useful, Let me know if there's anything else that you think it should cover! After updating the HTML parsing page and rediscovering some

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Steve Holden
Fred wrote: Here is the complete error from my Apache error log: Traceback (most recent call last): File /var/www/cgi-bin/mysqld_script_test.py, line 7, in ? import MySQLdb ImportError: No module named MySQLdb [Thu Jan 26 07:25:16 2006] [error] [client 127.0.0.1] malformed header

Re: Mining strings from a HTML document.

2006-01-26 Thread Cameron Laird
In article [EMAIL PROTECTED], Derick van Niekerk [EMAIL PROTECTED] wrote: . . . I suppose very few books on python start off with HTML processing in stead of 'hello world' :p . .

Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. xyz123aaabbaaabaaaabb I'm looking for a regular expression that matches the first, and only the first, sequence of the letter

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christoph Conrad
Hello Roger, I'm looking for a regular expression that matches the first, and only the first, sequence of the letter 'a', and only if the length of the sequence is exactly 3. import sys, re, os if __name__=='__main__': m = re.search('a{3}', 'xyz123aaabbaaaabaaabb') print

Re: Nitpicking - slightly misleading traceback

2006-01-26 Thread Sybren Stuvel
Juho Schultz enlightened us with: However, the bug sits on the next line. [...] I feel the traceback is misleading. Well, the bug sits in the command starting on the line indicated. Nitpick back: Learn about operator precedence and Python syntax rules. You don't need so many brackets: if

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Sybren Stuvel
Roger L. Cauvin enlightened us with: I'm looking for a regular expression that matches the first, and only the first, sequence of the letter 'a', and only if the length of the sequence is exactly 3. Your request is ambiguous: 1) You're looking for the first, and only the first, sequence of

replacing \n characters in a hash

2006-01-26 Thread Johhny
Hello, I am currently trying to write some scripts to get information from the xmlrpc for redhat network. One of the issues I am having is trying to strip off the special characters in the hash that is returned. Here is an example of the information returned within the hash : ===SNIP===

Re: Possible memory leak?

2006-01-26 Thread Tuvas
The times that I posted was the time that it took to perform ONE row iteration. As you can see, the time was going up, fairly dramatically. Why on earth could it be doing this? I understand the the time will fluctuate somewhat depending upon what else the CPU is doing, but, why is the base time

Re: www.mywebsite.py

2006-01-26 Thread Fuzzyman
Simon Brunning wrote: On 1/24/06, Cyril Bazin [EMAIL PROTECTED] wrote: Does someone ever tried (and succeed) to make an address like www.website.py. I found that the .py extension is given to the paraguay. I found this link ( http://www.nic.py/) but I don't speak spanish... If

sockets programming with python on mobile phones

2006-01-26 Thread al pacino
Hi everyone, Is it possible to write applications using sockets for network programming on MOBILE Phones( using Python on mobile phones such as nokia 66* series ) actually i want my mobile to 'TALK' to my pc 'WIRELESSLY' so i can send data between the two I think it works over the GPRS stack.

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Tim Chase
Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. xyz123aaabbaaabaaaabb I'm looking for a regular expression that matches the first, and only the first, sequence of the

Re: history

2006-01-26 Thread [EMAIL PROTECTED]
yqyq22 wrote: Dear all, another little question, I use idle 1.1.2, is there a way to use a history for the command line? Cursor up to a previously entered line and hit return. The line will be repeated, allowing editing. If the line was an entire block, the entire block will be repeated.

Re: replacing \n characters in a hash

2006-01-26 Thread Carsten Haese
On Thu, 2006-01-26 at 09:24, Johhny wrote: Hello, I am currently trying to write some scripts to get information from the xmlrpc for redhat network. One of the issues I am having is trying to strip off the special characters in the hash that is returned. Here is an example of the

Re: Nitpicking - slightly misleading traceback

2006-01-26 Thread Alex Martelli
Sybren Stuvel [EMAIL PROTECTED] wrote: ... if data[x][y] 0 or datadict.has_key(key): This might even make things fit on one line again ;-) Particularly if you code it idiomatically: if data[x][y] 0 or key in datadict: Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Assigning to self.__class__

2006-01-26 Thread Alex Martelli
Heiko Wundram [EMAIL PROTECTED] wrote: bruno at modulix wrote: Paul McGuire wrote: or am I taking advantage of a fortuitous accident, which may get undone at a future time? It's certainly not a fortuitous accident. And even the (printed) cookbook has examples which assign to

Re: replacing \n characters in a hash

2006-01-26 Thread Johhny
Hello, Thankyou for your response, If I check that the errara_package value is with a print I get the following. ===SNIP=== Updated libc-client packages that fix a buffer overflow issue are now available. This update has been rated as having moderate security impact by the Red Hat Security

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Alex Martelli
Tim Chase [EMAIL PROTECTED] wrote: ... I'm not quite sure what your intent here is, as the resulting find would obviously be aaa, of length 3. But that would also match ''; I think he wants negative loobehind and lookahead assertions around the 'aaa' part. But then there's the spec

Re: Pulling numbers from ASCII filename not working

2006-01-26 Thread Dave Hansen
On Thu, 26 Jan 2006 06:39:20 GMT in comp.lang.python, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On 25 Jan 2006 12:42:20 -0800, IamIan [EMAIL PROTECTED] declaimed the following in comp.lang.python: [...] I tried print repr(filename) and it returned the actual filename: 'n16w099.asc' ,

Re: replacing \n characters in a hash

2006-01-26 Thread Carsten Haese
On Thu, 2006-01-26 at 09:49, Johhny wrote: Hello, Thankyou for your response, If I check that the errara_package value is with a print I get the following. ===SNIP=== Updated libc-client packages that fix a buffer overflow issue are now available. This update has been rated as having

Re: Mining strings from a HTML document.

2006-01-26 Thread Magnus Lycka
Derick van Niekerk wrote: Could you/anyone explain the 4 lines of code to me though? A crash course in Python shorthand? What does it mean when you use two sets of brackets as in : beg = [1,0][text.startswith(s1)] ? It's not as strange as it looks. [1,0] is a list. If you put [] after a list,

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Magnus Lycka
Fred wrote: Slackware Linux 10.2 Heh, Slackware was my first Linux distro. Version 2.2 I think. 1993 maybe? Everything worked great up to this error when trying to load the webpage: ImportError: No module name MySQLdb Some suggestions: Start python interactively and try import MySQLdb.

Re: How to handle two-level option processing with optparse

2006-01-26 Thread Magnus Lycka
R. Bernstein wrote: I see how I missed this. Neither disable_.. or enable_.. have document strings. And neither seem to described in the optparser section (6.21) of the Python Library (http://docs.python.org/lib/module-optparse.html). http://docs.python.org/lib/optparse-other-methods.html --

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
Magnus Lycka wrote: Fred wrote: Slackware Linux 10.2 Heh, Slackware was my first Linux distro. Version 2.2 I think. 1993 maybe? I have been using Slackware since 1995, version 3.0 kernel 1.2.13 Some suggestions: Finally, the cgitb module is pretty useful. I suggest that you look it up:

Re: replacing \n characters in a hash

2006-01-26 Thread Johhny
Hello, Here is the code (minus my details section). server = xmlrpclib.ServerProxy(url) session = server.auth.login(username,password) #functions. def getErrata(): channel_label = 'rhel-i386-as-4' errata =

Re: replacing \n characters in a hash

2006-01-26 Thread Larry Bates
Johhny wrote: Hello, I am currently trying to write some scripts to get information from the xmlrpc for redhat network. One of the issues I am having is trying to strip off the special characters in the hash that is returned. Here is an example of the information returned within the hash :

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Christoph Conrad [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello Roger, I'm looking for a regular expression that matches the first, and only the first, sequence of the letter 'a', and only if the length of the sequence is exactly 3. import sys, re, os if

Re: Using non-ascii symbols

2006-01-26 Thread Terry Hancock
On Thu, 26 Jan 2006 01:12:10 -0600 Runsun Pan [EMAIL PROTECTED] wrote: For the tests that I tried earlier, using han characters as the variable names doesn't seem to be possible (Syntax Error) in python. I'd love to see if I can use han char for all those keywords like import, but it doesn't

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Tim Chase [EMAIL PROTECTED] wrote: ... I'm not quite sure what your intent here is, as the resulting find would obviously be aaa, of length 3. But that would also match ''; I think he wants negative loobehind and

Re: replacing \n characters in a hash

2006-01-26 Thread Fredrik Lundh
Johhny wrote: for vals in errata: print %s\t\t%s\t\t%s\t%s\t%s % (vals['errata_advisory'],vals['errata_issue_date'],vals['errata_update_date'],vals['errata_last_modified_date'],vals['errata_type'], ) errata_info = getPackage(vals['errata_advisory'],) print

Re: replacing \n characters in a hash

2006-01-26 Thread Steve Holden
Johhny wrote: Hello, Here is the code (minus my details section). server = xmlrpclib.ServerProxy(url) session = server.auth.login(username,password) #functions. def getErrata(): channel_label = 'rhel-i386-as-4' errata =

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christos Georgiou
On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. xyz123aaabbaaabaaaabb

Re: customized instance dictionaries, anyone?

2006-01-26 Thread Bengt Richter
On 25 Jan 2006 09:35:50 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: thx! indeed, it worked -- took me some time to figure out how to implement the setting of attributes, too. i finally managed to get that done using super: Seems good. snip the ``~.__setattr__()`` method tests for the

Re: sockets programming with python on mobile phones

2006-01-26 Thread Grant Edwards
On 2006-01-26, al pacino [EMAIL PROTECTED] wrote: Is it possible to write applications using sockets for network programming on MOBILE Phones( using Python on mobile phones such as nokia 66* series ) actually i want my mobile to 'TALK' to my pc 'WIRELESSLY' so i can send data between the

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christoph Conrad
Hello Roger, since the length of the first sequence of the letter 'a' is 2. Yours accepts it, right? Yes, i misunderstood your requirements. So it must be modified essentially to that what Tim Chase wrote: m = re.search('^[^a]*a{3}b', 'xyz123aabbaaab') Best wishes from germany,

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Sybren Stuvel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Roger L. Cauvin enlightened us with: I'm looking for a regular expression that matches the first, and only the first, sequence of the letter 'a', and only if the length of the sequence is exactly 3. Your request is

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Tim Chase
Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of exactly three. Ah...a little more clear. r = re.compile([^a]*a{3}b+(a+b*)*) matches = [s for s

Re: Pulling numbers from ASCII filename not working

2006-01-26 Thread Bengt Richter
On 25 Jan 2006 12:42:20 -0800, IamIan [EMAIL PROTECTED] wrote: Thank you for the replies, I'm new to Python and appreciate your patience. I'm using Python 2.1. To reiterate, the ASCII files in the workspace are being read correctly and their latitude values (coming from the filenames) are

Re: replacing \n characters in a hash

2006-01-26 Thread Johhny
Hello, In response to that the output is this : type 'str' 'Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security impact by the Red\nHat Security Response Team.' --

Re: Using non-ascii symbols

2006-01-26 Thread Rocco Moretti
Terry Hancock wrote: One thing that I also think would be good is to open up the operator set for Python. Right now you can overload the existing operators, but you can't easily define new ones. And even if you do, you are very limited in what you can use, and understandability suffers. One

Re: Executing script with embedded python

2006-01-26 Thread Andrew Ayre
Farshid Lashkari [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The problem is that PyObject_CallObject always returns NULL. Is this the correct return value for simply executing a script, as there is no function return value involved? The documentation for PyObject_CallObject

urllib2 chunked encoding

2006-01-26 Thread Sean Harper
I am trying to download some html using mechanize:br=Browser()r = br.open(url)b = r.read()print bI have used this code successfully many times and now I have run across an instance where it fails. It opens the url without error but then prints nothing. Looking at the http headers when it works

Re: replacing \n characters in a hash

2006-01-26 Thread Fredrik Lundh
(since this is a newsgroup, can you please quote the message you're replying to). Johhny wrote: In response to that the output is this : type 'str' 'Updated libc-client packages that fix a buffer overflow issue are now\navailable.\n\nThis update has been rated as having moderate security

Re: MySQLdb - Query/fetch don't return result when it *theorically* should

2006-01-26 Thread Mark Hertel
On Wed, 18 Jan 2006 18:31:39 -0500, Bernard Lebel [EMAIL PROTECTED] wrote: I'm absolutely flabbergasted. Your suggestion worked, the loop now picks up the changed values, and without the need to reconnect. It's the first time I have to commit after a query, up until I wrote this program, I

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Alex Martelli
Tim Chase [EMAIL PROTECTED] wrote: Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of exactly three. Ah...a little more clear. r =

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christoph Conrad
Hallo Alex, r = re.compile([^a]*a{3}b+(a+b*)*) matches = [s for s in listOfStringsToTest if r.match(s)] Unfortunately, the OP's spec is even more complex than this, if we are to take to the letter what you just quoted; e.g. aazaaab SHOULD match, Then it's again a{3}b, isn't it? Freundliche

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Tim Chase [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of exactly three. Ah...a little more clear.

Re: history

2006-01-26 Thread Claudio Grondi
yqyq22 wrote: Dear all, another little question, I use idle 1.1.2, is there a way to use a history for the command line? thanks in advance Another possibility beside going to any of the previous lines and hitting [Return]: [Alt]+p Claudio --

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Christos Georgiou [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Tim Chase
r = re.compile([^a]*a{3}b+(a+b*)*) matches = [s for s in listOfStringsToTest if r.match(s)] Wow, I like it, but it allows some strings it shouldn't. For example: xyz123aabbaaab (It skips over the two-letter sequence of 'a' and matches 'bbaaab'.) Anchoring it to the beginning/end might

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Peter Hansen
Roger L. Cauvin wrote: Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of exactly three. Hope that's clearer . . . . Examples are a *really* good way to

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Tim Chase [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] r = re.compile([^a]*a{3}b+(a+b*)*) matches = [s for s in listOfStringsToTest if r.match(s)] Wow, I like it, but it allows some strings it shouldn't. For example: xyz123aabbaaab (It skips over the two-letter sequence of 'a'

Re: ANN: SPE 0.8.2.a Python IDE: configure styles, interactive terminals ubuntu

2006-01-26 Thread Claudio Grondi
SPE - Stani's Python Editor wrote: Release news from http://pythonide.stani.be This is an important a bugfix release for all platforms. As new features it can customize your fonts and colors (styles), supports interactive terminals and has improved support for Ubuntu. Thanks to Marco

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Peter Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Roger L. Cauvin wrote: Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of exactly three.

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Alex Martelli
Christoph Conrad [EMAIL PROTECTED] wrote: Hello Roger, since the length of the first sequence of the letter 'a' is 2. Yours accepts it, right? Yes, i misunderstood your requirements. So it must be modified essentially to that what Tim Chase wrote: m = re.search('^[^a]*a{3}b',

Tkinter listener thread?

2006-01-26 Thread gregarican
I have a Python UDP listener socket that waits for incoming data. The socket runs as an endless loop. I would like to pop the incoming data into an existing Tkinter app that I have created. What's the easiest/most efficient way of handling this? Would I create a separate thread that has the

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christos Georgiou
On Thu, 26 Jan 2006 16:26:57 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Christos Georgiou [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Say I

Re: Using non-ascii symbols

2006-01-26 Thread Claudio Grondi
Rocco Moretti wrote: Terry Hancock wrote: One thing that I also think would be good is to open up the operator set for Python. Right now you can overload the existing operators, but you can't easily define new ones. And even if you do, you are very limited in what you can use, and

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Alex Martelli [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Tim Chase [EMAIL PROTECTED] wrote: Sorry for the confusion. The correct pattern should reject all strings except those in which the first sequence of the letter 'a' that is followed by the letter 'b' has a length of

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Christos Georgiou
On Thu, 26 Jan 2006 16:41:08 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Good suggestion. Here are some test cases: xyz123aaabbab accept xyz123aabbaab reject xayz123aaabab accept xaaayz123abab reject xaaayz123aaabab accept Applying my last regex to your test

Re: ImportError: No module name MySQLdb

2006-01-26 Thread Fred
I have discovered the possible problem (I can't check this until later when I am home) I think when I upgraded to Python 2.4.2 it created my problem. Below is what is going on: Default Slackware 10.2 install - 2.4.1 installed into /usr/lib/python2.4 Python 2.4.1 upgraded to 2.4.2 Upgrade

  1   2   3   >