[regex] Basic rewriting

2007-11-20 Thread Gilles Ganault
Hello I've been reading tutorials on regexes in Python, but I still don't get it: #!/usr/bin/python #myscript.py 0123456789 import sys,re #Turn 0123456789 into 01.23.45.67.89 p = re.compile('(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)') phone = p.sub('\1.\2.\3.\4.\5',sys.argv[1]) print

Re: [regex] Basic rewriting

2007-11-20 Thread Gilles Ganault
On Tue, 20 Nov 2007 21:57:43 -0500, J. Clifford Dyer [EMAIL PROTECTED] wrote: Use raw strings for re expressions. Thanks guys for the prompt reply :-) Solved it. -- http://mail.python.org/mailman/listinfo/python-list

[issue1437] List member inside a class is shared by all instances of the class

2007-11-13 Thread Quentin Gallet-Gilles
Quentin Gallet-Gilles added the comment: That's the expected behavior, actually. The variables 'arr' and 's' are static variables in the class Blah. This is discussed in several places in the doc and the FAQ, e.g. http://www.python.org/doc/faq/programming/#how-do-i-create-static-class-data

[issue1127] No tests for inspect.getfullargspec()

2007-11-08 Thread Quentin Gallet-Gilles
Quentin Gallet-Gilles added the comment: Alright, thanks! __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1127 __ ___ Python-bugs-list mailing list Unsubscribe: http

[issue1127] No tests for inspect.getfullargspec()

2007-09-22 Thread Quentin Gallet-Gilles
New submission from Quentin Gallet-Gilles: I created 4 tests, see attached 'test_getfullargspec.diff' patch. 2 tests verify that getargspec raises ValueError when trying to call it with the function containing keyword-only arguments or annotations. The 2 others call getfullargspec and check

[issue1146] TextWrap vs words 1-character shorter than the width

2007-09-14 Thread Quentin Gallet-Gilles
Quentin Gallet-Gilles added the comment: The bug is present in trunk and has been there since rev 33955. This revision contained a fix to an infinite loop when indentation was set longer than width with long word breaking enabled. In that case, it would strip off at least one character on every

[issue1146] TextWrap vs words 1-character shorter than the width

2007-09-14 Thread Quentin Gallet-Gilles
Quentin Gallet-Gilles added the comment: The previous patch is suboptimal and doesn't solve all cases. This one does. My apologies. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1146

[issue1146] TextWrap vs words 1-character shorter than the width

2007-09-14 Thread Quentin Gallet-Gilles
Changes by Quentin Gallet-Gilles: __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1146 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options

Re: Reading a two-column file into an array?

2007-08-02 Thread Gilles Ganault
On Tue, 31 Jul 2007 08:41:45 -0700, [EMAIL PROTECTED] (Alex Martelli) wrote: That's what 2.5's with statement is all about...: Thanks everyone. Python power :-) from __future__ import with_statement import csv with open('import.csv', 'rb') as f: for item in list(csv.reader(f,

Re: Why no maintained wrapper to Win32?

2007-07-30 Thread Gilles Ganault
On Sun, 29 Jul 2007 21:49:04 -0700, sturlamolden [EMAIL PROTECTED] wrote: Why inflict suffering on yourself with MFC when you can use wxPython or PyGTK? Because I'd like to avoid having to pack several MB + having to install the toolkit. Considering the size of the typical Python script, it

[2.5] Reading a two-column file into an array?

2007-07-30 Thread Gilles Ganault
Hello I'm sure there's a much easier way to read a two-column, CSV file into an array, but I haven't found it in Google. Should I use the Array module instead? = a = [] i = 0 #itemTABitemCRLF p = re.compile(^(.+)\t(.+)$) for line in textlines: m = p.search(line) if m:

Re: Why no maintained wrapper to Win32?

2007-07-29 Thread Gilles Ganault
On Sun, 29 Jul 2007 06:40:35 +0200, Martin v. Löwis [EMAIL PROTECTED] wrote: Why do you say that the Win32 API lacks documentation? I find the documentation at msdn.microsoft.com to be quite useful. No, I meant documentation on how to write Win32 apps using PyWin. Yes, there haven't been many

Re: Why no maintained wrapper to Win32?

2007-07-29 Thread Gilles Ganault
On Sun, 29 Jul 2007 19:33:40 -0700, sturlamolden [EMAIL PROTECTED] wrote: You mean 'total lack of documentation' besides Mark Hammond's O'Reilly book on Windows programming in Python? Sorry, I thought that book was way outdated because it uses Python 1.5. Not to mention MSDN, Charles Petzold's

Why no maintained wrapper to Win32?

2007-07-28 Thread Gilles Ganault
Hello It looks like the development of the PyWin32 wrapper to the Win32 API stopped years ago, which is too bad because it means that writing GUI apps in Python even just for Windows means adding megabytes when using eg. wxWidgets. How come no one too over this project, or offered

Re: Why no maintained wrapper to Win32?

2007-07-28 Thread Gilles Ganault
On Sat, 28 Jul 2007 18:05:34 +0200, Martin v. Löwis [EMAIL PROTECTED] wrote: Why does it mean that? The Win32 APIs for GUI are up-to-date; they don't need further development. Win32 itself stopped years ago. You can write GUI applications with PyWin32 just fine. Besides the total lack of

Re: [2.5] Regex doesn't support MULTILINE?

2007-07-23 Thread Gilles Ganault
On Sun, 22 Jul 2007 05:34:17 -0300, Gabriel Genellina [EMAIL PROTECTED] wrote: Try to avoid using .* and .+ (even the non greedy forms); in this case, I think you want the scan to stop when it reaches the ending /span or any other tag, so use: [^]* instead. BTW, better to use a raw string to

[2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Gilles Ganault
Hello I'm trying to extract information from a web page using the Re module, but it doesn't seem to support MULTILINE: = import re #NO CRLF : works response = bBla/bblablafont color=#123 #CRLF : doesn't work response = bBla/bblabla\r\nfont color=#123 pattern = bBla/b.+?font

Re: [2.5] Regex doesn't support MULTILINE?

2007-07-21 Thread Gilles Ganault
On Sat, 21 Jul 2007 22:18:56 -0400, Carsten Haese [EMAIL PROTECTED] wrote: That's your problem right there. RE is not the right tool for that job. Use an actual HTML parser such as BeautifulSoup Thanks a lot for the tip. I tried it, and it does look interesting, although I've been unsuccessful

[2.5] Script to POST to web page with cookies?

2007-07-19 Thread Gilles Ganault
Hello I need to write a script to automate fetching data from a web site: 1. using the POST method, log on, with login/password saved as cookies 2. download page and extract relevent information using regexes 3. log off 4. wait for a random number of minutes, and GOTO 1 I'm a bit confused with

GUI apps in Windows with native widgets?

2007-06-18 Thread Gilles Ganault
Hello I'd like to write a GUI app in Python exclusively for Windows. Apparently, development of PythonWin has stopped a long time ago. Is there another thin wrapper to write apps in Windows? I'd rather not have to ship eg. WxWidgets, GTK+, or QT. Thank you. --

Re: Building browser-like GET request

2007-04-24 Thread Gilles Ganault
On Sun, 22 Apr 2007 18:07:57 -0400, Steve Holden [EMAIL PROTECTED] wrote: On a point of information, Wireshark wokrs very effectively under Windows. The only thing you shouldn't expect to be able to do is tap into the loopback network, and that's down to the Windows driver structure. Thanks for

[SQLite] Recommended wrapper?

2007-04-23 Thread Gilles Ganault
Hello I browsed through the SQLite archives at Gname, but most threads regarding wrappers for Python date back to 2005, and for this ng, Google returns stuff from 2006 as the most relevant posts, so I figured I should ask here before diving in. There are several wrappers listed in the

Re: [re.finditer] Getting all occurences in one go?

2007-04-23 Thread Gilles Ganault
On 22 Apr 2007 15:33:37 -0700, Paul Rubin http://[EMAIL PROTECTED] wrote: mytable[item] = ','.join(m.group(1) for m in matches) Thanks, that did it. -- http://mail.python.org/mailman/listinfo/python-list

Re: [SQLite] Recommended wrapper?

2007-04-23 Thread Gilles Ganault
On Mon, 23 Apr 2007 16:03:05 +0200, Thomas Krüger [EMAIL PROTECTED] wrote: It's all there: http://docs.python.org/lib/module-sqlite3.html Thanks. -- http://mail.python.org/mailman/listinfo/python-list

[re.finditer] Getting all occurences in one go?

2007-04-22 Thread Gilles Ganault
Hello I'd like to make sure there isn't an easier way to extract all the occurences found with re.finditer: === req = urllib2.Request(url, None, headers) response = urllib2.urlopen(req).read() matches = re.compile((\d+).html).finditer(response) # --- BEGIN for match

Re: [re.finditer] Getting all occurences in one go?

2007-04-22 Thread Gilles Ganault
On Sun, 22 Apr 2007 23:28:23 +0200, Gilles Ganault [EMAIL PROTECTED] wrote: I'd like to make sure there isn't an easier way to extract all the occurences found with re.finditer: Oops, s/match/item/: req = urllib2.Request(url, None, headers) response = urllib2.urlopen(req).read() matches

Building browser-like GET request

2007-04-21 Thread Gilles Ganault
Hello I'd like to download pages from a site, but it checks whether the requests are coming from a live user or a script; If the latter, the server returns a blank page. Using a proxy (Paros), I can see what information my script and FireFox send, and there are a lot of information that

Re: Building browser-like GET request

2007-04-21 Thread Gilles Ganault
On 21 Apr 2007 14:47:55 -0700, Björn Keil [EMAIL PROTECTED] wrote: Well, I am brand new to Python, so it takes me a lot of guessing, but since it seems you're using urlib2: Thanks. Indeed, it looks like urlib2 is the way to go when going through a proxy. For those interested, here's how to

wxPython Cygwin

2005-10-13 Thread Gilles DRIDI
Does someone has installed wxPython on the Cygwin platform, environment ? Thank you Gilles DRIDI http://cdridi.club.fr -- http://mail.python.org/mailman/listinfo/python-list

Linux/Python - SQL*Server Connexion chain

2005-09-22 Thread Gilles Lenfant
Hi, Have you guys any good experience on connecting a Python (Zope) app running on Linux to a Windoze SQL*Server ? Many thanks by advance to report your success, failure, pitfalls (...) and used products. Even reports using commercial solutions are welcome. -- Gilles -- http

Subprocess and time-out

2005-06-16 Thread Gilles Lenfant
deadlocked) and to process the next file. Unfortunately, I didn't find any pythonic stuff to control the time spent runnning subprocesses (and kill'em if needed) launched with popen. An hint is welcome. Many thanks by advance. -- Gilles Lenfant -- http://mail.python.org/mailman/listinfo/python

Re: [OT ?] (Pythonic) detection word protected files

2005-06-14 Thread Gilles Lenfant
Tim Golden a écrit : [Gilles Lenfant] | I'm building an utility that makes a catalog of M$ word files | in a giant | directory tree. The password protected files must be marked, and I | didn't find how to guess which files are password protected and which | ones are not. | | I can't

Re: [OT ?] (Pythonic) detection word protected files

2005-06-14 Thread Gilles Lenfant
or not) in the UNO API. Anyway UNO is somehow overkill to get something like a pair of bytes at some position in the file (4 or 5 python lines with the standard packages). Many thanks -- Gilles -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python Suitable for Large Find Replace Operations?

2005-06-14 Thread Gilles Lenfant
file(s) with markup (XML, CSV, ...) ? -- Gilles -- http://mail.python.org/mailman/listinfo/python-list

[OT ?] (Pythonic) detection word protected files

2005-06-13 Thread Gilles Lenfant
ones are not. I can't use the COM interface for this because the utility must run on a Linux Samba server. I didn't find anything satisfying in M$ related sites (like msdn) or forums or google. Any hint ? Many thanks by advance. -- Gilles -- http://mail.python.org/mailman/listinfo/python-list

Using PyOpenGL what should I use for a GUI ?

2005-02-26 Thread Gilles Leblanc
Hi I have started a small project with PyOpenGL. I am wondering what are the options for a GUI. So far I checked PyUI but it has some problems with 3d rendering outside the Windows platform. I know of WxPython but I don't know if I can create a WxPython window, use gl rendering code in it and

Re: how to pass attribute name via sys.argv

2005-01-27 Thread Gilles Lenfant
. class Foo(object): pass objekt = Foo() attrName = sys.argv[1] values = ['foo', 'bar', 'whatever'] setattr(objekt, attrName, values) HTH -- Gilles -- http://mail.python.org/mailman/listinfo/python-list

bad argument type for built-in operation

2005-01-24 Thread Gilles Arnaud
Hello, I've got a nasty bug and no idea to deal with : here is the method : method def denormer(self, var) : denorme un vecteur d'entree try: #a = map(self.decerner, self.param, var) #a = [self.decerner(x, y) for x, y in map(None, self.param, var)]

<    1   2   3   4