Re: regular expression help

2010-11-29 Thread goldtech
.*? fixed it. Every occurrence of the pattern is now affected, which is what I want. Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

[ANNOUNCE] Twisted 10.2.0 Released

2010-11-29 Thread Glyph Lefkowitz
Twisted 10.2.0, the third Twisted release of 2010, has emerged from the mysterious depths of Twisted Matrix Labs, as so many releases before it. Survivors of the release process - what few there were of them - have been heard to claim that this version is "awesome", "even more robust", "fun-siz

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-29 Thread Yingjie Lan
--- On Tue, 11/30/10, Dan Stromberg wrote: > In Python 3, I'm finding that I have encoding issues with > characters > with their high bit set.  Things are fine with strictly > ASCII > filenames.  With high-bit-set characters, even if I > change stdin's > encoding with: Co-ask. I have also had pro

Re: regular expression help

2010-11-29 Thread Tim Harig
Python 3.1.2 (r312:79147, Oct 9 2010, 00:16:06) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> m="cccvlvlvlvnnnflfllffccclfnnnooo" >>> pattern = re.compile(r'ccc[^n]*nnn') >>> pattern.sub("||", m) '||flfllff||ooo' >>> # or, as

Re: regular expression help

2010-11-29 Thread Tim Harig
On 2010-11-30, goldtech wrote: > Hi, > > say: import re > m="cccvlvlvlvnnnflfllffccclfnnnooo" re.compile(r'ccc.*nnn') rtt=.sub("||",m) rtt > '||ooo' > > The regex is eating up too much. What I want is every non-overlapping > occurrence I think. > > so rtt would

Re: regular expression help

2010-11-29 Thread Yingjie Lan
--- On Tue, 11/30/10, goldtech wrote: > From: goldtech > Subject: regular expression help > To: python-list@python.org > Date: Tuesday, November 30, 2010, 9:17 AM > The regex is eating up too much. What I want is every > non-overlapping > occurrence I think. > > so rtt would be: > > '||flf

Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-11-29 Thread Dan Stromberg
I've got a couple of programs that read filenames from stdin, and then open those files and do things with them. These programs sort of do the *ix xargs thing, without requiring xargs. In Python 2, these work well. Irrespective of how filenames are encoded, things are opened OK, because it's all

regular expression help

2010-11-29 Thread goldtech
Hi, say: >>> import re m="cccvlvlvlvnnnflfllffccclfnnnooo" >>> re.compile(r'ccc.*nnn') >>> rtt=.sub("||",m) >>> rtt '||ooo' The regex is eating up too much. What I want is every non-overlapping occurrence I think. so rtt would be: '||flfllff||ooo' just like findall acts bu

Re: TDD in python

2010-11-29 Thread rustom
On Nov 29, 4:59 pm, André wrote: > On Nov 29, 7:31 am, rustom wrote: > > > > > On Nov 28, 7:52 pm, Stefan Behnel wrote: > > > > Rustom Mody, 28.11.2010 11:58: > > > > > Does anyone know of something like this for python? > > > > >http://www.vimeo.com/13240481 > > > > The page seems to require a

Re: Parsing markup.

2010-11-29 Thread Alan Meyer
On 11/29/2010 11:20 AM, Joe Goldthwaite wrote: Hi MRAB, I was trying to avoid regex because my poor old brain has trouble with it. I have to admin though, that line is slick! I'll have to go through my regex documentation to try and figure out what it actually means. Personally, I'd be hesita

Re: Reading lines of null-terminated text?

2010-11-29 Thread Ian Kelly
On Mon, Nov 29, 2010 at 4:17 PM, MRAB wrote: > In Python 3 it's possible to specify the newline character, but I've > found that it won't accept the null character as newline. I don't know > why. :-( Because it isn't a legal value. "newline controls how universal newlines works (it only applies

Re: Reading lines of null-terminated text?

2010-11-29 Thread MRAB
On 29/11/2010 21:44, Dan Stromberg wrote: What's the best way of reading lines of null terminated (ASCII NUL, \0) text in Python 2.x? How about for 3.x? I've been using http://stromberg.dnsalias.org/~strombrg/readline0.html with 2.x, but I'm moving some of my stuff to 3.x, and am wondering if

Re: Python 2.7.1

2010-11-29 Thread Spider
> 2.7 includes many features that were first released in Python 3.1. The faster > io module ... I understand that I/O in Python 3.0 was slower than 2.x (due to quite a lot of the code being in Python rather than C, I gather), and that this was fixed up in 3.1. So, io in 3.1 is faster than in 3.0.

Re: Arrays

2010-11-29 Thread Garland Fulton
At the top of the last post I didn't understand how I was supposed to have my e mail headers or my quotes formatted. I also would like to change the header to my e mail thread. To I appolpgize and thank you for clearing up my thinking. I just got done with a java class and I should have paid mo

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-29 Thread Gregory Ewing
Paul Rubin wrote: The classic example though is a window system, where you have a "window" class, and a "scroll bar" class, and a "drop-down menu" class, etc. and if you want a window with a scroll bar and a drop-down menu, you inherit from all three of those classes. Not in any GUI library I'

Re: sqlite autoincrement of primary key

2010-11-29 Thread tinauser
On Nov 29, 10:49 pm, "D'Arcy J.M. Cain" wrote: > On Mon, 29 Nov 2010 19:11:18 + (UTC) > > Tim Harig wrote: > > >   INSERT INTO foo (name) VALUES ('xxx') > > > > That's the standard SQL way. > > > Yes, it works; but, the OP asked specifically to be able to enter all of > > the field values, in

Re: Help required with Tranformation of coordinate system

2010-11-29 Thread BansalMaddy
On Nov 29, 8:33 pm, Terry Reedy wrote: > On 11/29/2010 1:55 AM, BansalMaddy wrote: > > > > > On Nov 29, 2:03 am, Terry Reedy  wrote: > >> On 11/28/2010 6:36 PM, BansalMaddy wrote: > > >>> hi all! > >>> i need a help in python! i am struggling to implement this since last > >>> 2/3 days. suppose i

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, D'Arcy J.M. Cain wrote: > On Mon, 29 Nov 2010 19:11:18 + (UTC) > Tim Harig wrote: >> > INSERT INTO foo (name) VALUES ('xxx') >> > >> > That's the standard SQL way. >> >> Yes, it works; but, the OP asked specifically to be able to enter all of >> the field values, including t

Re: sqlite autoincrement of primary key

2010-11-29 Thread D'Arcy J.M. Cain
On Mon, 29 Nov 2010 19:11:18 + (UTC) Tim Harig wrote: > > INSERT INTO foo (name) VALUES ('xxx') > > > > That's the standard SQL way. > > Yes, it works; but, the OP asked specifically to be able to enter all of > the field values, including the autoincrement field. You're right, I missed th

Reading lines of null-terminated text?

2010-11-29 Thread Dan Stromberg
What's the best way of reading lines of null terminated (ASCII NUL, \0) text in Python 2.x? How about for 3.x? I've been using http://stromberg.dnsalias.org/~strombrg/readline0.html with 2.x, but I'm moving some of my stuff to 3.x, and am wondering if there's a way that would obviate readline0.

Re: Use company name for module

2010-11-29 Thread JKPeck
On Nov 29, 1:41 pm, Chris Withers wrote: > On 12/11/2010 15:50, Robert Kern wrote: > > > > > On 11/12/10 8:12 AM, Micah Carrick wrote: > >> My company is working on releasing some of our code as open-source python > >> modules. I don't want my "foo" module conflicting with other modules > >> calle

Re: Use company name for module

2010-11-29 Thread Chris Withers
On 12/11/2010 15:50, Robert Kern wrote: On 11/12/10 8:12 AM, Micah Carrick wrote: My company is working on releasing some of our code as open-source python modules. I don't want my "foo" module conflicting with other modules called "foo" on PyPi or github or a user's system. Is there anything wr

Re: sqlite autoincrement of primary key

2010-11-29 Thread Alan Meyer
On 11/29/2010 1:12 PM, tinauser wrote: Dear List I'm writing an application that has to create and populate an SQLite database. I'm doing pretty well, but now I'm facing a problem I can not solve. I create a table with a primary key autoincrement, something like sqlcmd="CREATE TABLE foo (id INT

Re: Python 2.7.1

2010-11-29 Thread Terry Reedy
On 11/29/2010 6:51 AM, Kent Johnson wrote: On Nov 27, 11:33 pm, Benjamin Peterson wrote: On behalf of the Python development team, I'm happy as a clam to announce the immediate availability of Python 2.7.1. Will there be Mac binaries for 2.7.1 and 3.1.3? Currently the web site shows only sour

Re: Help required with Tranformation of coordinate system

2010-11-29 Thread Terry Reedy
On 11/29/2010 1:55 AM, BansalMaddy wrote: On Nov 29, 2:03 am, Terry Reedy wrote: On 11/28/2010 6:36 PM, BansalMaddy wrote: hi all! i need a help in python! i am struggling to implement this since last 2/3 days. suppose i have a 2D plot (say y=x**2). now on the same plot i want to transform my

Re: sqlite autoincrement of primary key

2010-11-29 Thread tinauser
On Nov 29, 7:28 pm, Tim Harig wrote: > On 2010-11-29, tinauser wrote: > > > ''' > > INSERT INTO 'foo' VALUES (?,?) > > ''' > > ,('NULL','yyy')) > > s/'NULL'/None/ > > > I get a datatype mismatch error. > > The sqlite module is smart enough to convert between Python types and > Sqlite types.  If y

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, D'Arcy J.M. Cain wrote: > On Mon, 29 Nov 2010 13:19:19 -0500 > Mel wrote: >> tinauser wrote: >> '''INSERT INTO foo VALUES (NULL, ?)''' > > Does this work in SQLite: > > INSERT INTO foo (name) VALUES ('xxx') > > That's the standard SQL way. Yes, it works; but, the OP asked specif

Strategies for unit testing an HTTP server.

2010-11-29 Thread Alice Bevan–McGregor
Hello! Two things are missing from the web server I've been developing before I can release 1.0: unit tests and documentation. Documentation being entirely my problem, I've run into a bit of a snag with unit testing; just how would you go about it? Specifically, I need to test things like H

Re: sqlite autoincrement of primary key

2010-11-29 Thread D'Arcy J.M. Cain
On Mon, 29 Nov 2010 13:19:19 -0500 Mel wrote: > tinauser wrote: > '''INSERT INTO foo VALUES (NULL, ?)''' Does this work in SQLite: INSERT INTO foo (name) VALUES ('xxx') That's the standard SQL way. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/

Re: sqlite autoincrement of primary key

2010-11-29 Thread Tim Harig
On 2010-11-29, tinauser wrote: > ''' > INSERT INTO 'foo' VALUES (?,?) > ''' > ,('NULL','yyy')) s/'NULL'/None/ > I get a datatype mismatch error. The sqlite module is smart enough to convert between Python types and Sqlite types. If you pass it 'NULL' it thinks you are passing it a string. Pyth

Re: sqlite autoincrement of primary key

2010-11-29 Thread John Bokma
tinauser writes: > however, if in python i try to execute a script like: > > cur.execute( > ''' > INSERT INTO 'foo' VALUES (?,?) > ''' > ,('NULL','yyy')) ,(None, 'yyy')) Or use VALUES(NULL, ?) as suggested in another post. -- John Bokma

Re: sqlite autoincrement of primary key

2010-11-29 Thread Mel
tinauser wrote: > Normally, the sqlite command that works would be > > INSERT INTO 'foo' VALUES (NULL, 'yyy' ) > > however, if in python i try to execute a script like: > > cur.execute( > ''' > INSERT INTO 'foo' VALUES (?,?) > ''' > ,('NULL','yyy')) > > I get a datatype mismatch error. > > Ha

sqlite autoincrement of primary key

2010-11-29 Thread tinauser
Dear List I'm writing an application that has to create and populate an SQLite database. I'm doing pretty well, but now I'm facing a problem I can not solve. I create a table with a primary key autoincrement, something like sqlcmd="CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT

Re: How do you find out what's happening in a process?

2010-11-29 Thread Michele Simionato
On Nov 29, 7:01 am, Leo Jay wrote: > Hi all, > > I'd like to know how do you guys find out what's happening in your > code if the process seems not work. > In java, I will use jstack to check stacks of threads and lock status. > But I don't know how to do it in python. > > -- > Best Regards, > Le

Re: Parsing markup.

2010-11-29 Thread Stefan Behnel
Jon Clements, 26.11.2010 13:58: On Nov 26, 4:03 am, MRAB wrote: On 26/11/2010 03:28, Joe Goldthwaite wrote: > I’m attempting to parse some basic tagged markup. The output of the > TinyMCE editor returns a string that looks something like this; > > This is a paragraph withbold andit

RE: Parsing markup.

2010-11-29 Thread Joe Goldthwaite
Hi MRAB, I was trying to avoid regex because my poor old brain has trouble with it. I have to admin though, that line is slick! I'll have to go through my regex documentation to try and figure out what it actually means. Thanks! -Original Message- From: python-list-bounces+joe=goldthwai

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-29 Thread Giampaolo Rodolà
2010/11/24 Raymond Hettinger : > I'm writing-up more guidance on how to use super() and would like to > point at some real-world Python examples of cooperative multiple > inheritance. > > Google searches take me to old papers for C++ and Eiffel, but that > don't seem to be relevant to most Python p

Re: How do you find out what's happening in a process?

2010-11-29 Thread Ulrich Eckhardt
Leo Jay wrote: > I'd like to know how do you guys find out what's happening in your > code if the process seems not work. > In java, I will use jstack to check stacks of threads and lock > status. But I don't know how to do it in python. import pdb pdb.set_trace() Generally, searching "python de

How to start a windows application minimized (or hidden)

2010-11-29 Thread klausfpga
Hi, I'd like to start a windows application minimized As an example I used calc.exe what I tried was using the startupinfo field of subprocess.Popen though I'm not sure, that 'hidden' is really the same as minimized. st_info = subprocess.STARTUPINFO() st_info.dwFlags |= subproc

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-29 Thread Kirill Simonov
Hi Raymond, Another example: extensions in Mercurial. Mercurial is a VCS with a typical command line syntax: $ hg Mercurial has an extension mechanism for adding new and modifying existing commands. A big chunk of Mercurial functionality is implemented in `ui` and `repo` classes and ext

Re: hashlib in one line

2010-11-29 Thread Thomas Guettler
Thank you, I was blind: See "condensed": http://docs.python.org/library/hashlib.html Stefan Sonnenberg-Carstens wrote: > Am 29.11.2010 14:50, schrieb Thomas Guettler: >> Hi, >> >> I think it would be nice if you could use the hashlib in one line: >> >> hashlib.sha256().update('abc').hexdigest()

Re: Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-29 Thread python
Michele and Terry, > From: "Michele Simionato" > > Notice that you can upgrade a Tkinter class to a new-style class simply by > deriving from object. For instance you could define a new-style Label class > as: > > class Label(Tkinter.Label, object): > pass Michele - your technique is *exactl

Re: hashlib in one line

2010-11-29 Thread Stefan Sonnenberg-Carstens
Am 29.11.2010 14:50, schrieb Thomas Guettler: Hi, I think it would be nice if you could use the hashlib in one line: hashlib.sha256().update('abc').hexdigest() Unfortunately update() returns None. Is there a way to convert a string to the hexdigest of sha256 in one line? Thomas Like so

Re: hashlib in one line

2010-11-29 Thread J. Gerlach
Am 29.11.2010 14:50, schrieb Thomas Guettler: > Hi, > > I think it would be nice if you could use the hashlib in one line: > > hashlib.sha256().update('abc').hexdigest() > > Unfortunately update() returns None. > > Is there a way to convert a string to the hexdigest of sha256 in one line? > >

hashlib in one line

2010-11-29 Thread Thomas Guettler
Hi, I think it would be nice if you could use the hashlib in one line: hashlib.sha256().update('abc').hexdigest() Unfortunately update() returns None. Is there a way to convert a string to the hexdigest of sha256 in one line? Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mai

Re: TDD in python

2010-11-29 Thread André
On Nov 29, 7:31 am, rustom wrote: > On Nov 28, 7:52 pm, Stefan Behnel wrote: > > > Rustom Mody, 28.11.2010 11:58: > > > > Does anyone know of something like this for python? > > > >http://www.vimeo.com/13240481 > > > The page seems to require a recent version of the Flash player. Could you > > de

Re: Python 2.7.1

2010-11-29 Thread Kent Johnson
On Nov 27, 11:33 pm, Benjamin Peterson wrote: > On behalf of the Python development team, I'm happy as a clam to announce the > immediate availability of Python 2.7.1. Will there be Mac binaries for 2.7.1 and 3.1.3? Currently the web site shows only source and Windows binaries. Thanks, Kent --

Re: TDD in python

2010-11-29 Thread rustom
On Nov 28, 7:52 pm, Stefan Behnel wrote: > Rustom Mody, 28.11.2010 11:58: > > > Does anyone know of something like this for python? > > >http://www.vimeo.com/13240481 > > The page seems to require a recent version of the Flash player. Could you > describe what exactly you are looking for? > > Stef

Re: Comparing floats

2010-11-29 Thread Marco Nawijn
On 29 nov, 00:20, Nobody wrote: > On Sat, 27 Nov 2010 18:23:48 -0500, Terry Reedy wrote: > >> Therefore, to implement this multiplication operation I need to have a > >> way to verify that the float tuples C and D are "equal". > > > I might try the average relative difference: > > sum(abs((i-j)/(i

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-29 Thread Michele Simionato
On Nov 28, 2:01 pm, m...@distorted.org.uk (Mark Wooding) wrote: > Steve Holden writes: > > It isn't. Even inheritance itself isn't as useful as it at first > > appears, and composition turns out in practice to be much more useful. > > That goes double for multiple inheritance. > > Composition /wit

Re: Using property() to extend Tkinter classes but Tkinter classes are old-style classes?

2010-11-29 Thread Michele Simionato
On Nov 29, 12:15 am, Terry Reedy wrote: > On 11/28/2010 3:47 PM, pyt...@bdurham.com wrote: > > > I had planned on subclassing Tkinter.Toplevel() using property() to wrap > > access to properties like a window's title. > > After much head scratching and a peek at the Tkinter.py source, I > > realiz

Re: Standard module implementation

2010-11-29 Thread Daniel Molina Wegener
On Domingo 28 Noviembre 2010 11:08, candide wrote: > I was wondering if all the standard module are implemented in C. For > instance, I can't find a C implementation for the minidom xml parser > under Python 2.6. If you are looking for a C implementation of DOM as Python Extension, you can try

Re: remote control firefox with python

2010-11-29 Thread Daniel Molina Wegener
On Domingo 28 Noviembre 2010 18:58, News123 wrote: > On 11/28/2010 06:19 PM, Tim Harig wrote: >> On 2010-11-28, News123 wrote: >>> Thanks in advance for any pointers ideas. >> >> google XPCOM > thanks a lot For XPCOM (I've worked with it), you can try the following articles and references: "XP

Re: remote control firefox with python

2010-11-29 Thread Simon Brunning
On 28 November 2010 15:22, News123 wrote: > > I wondered whether there is a simpe way to > 'remote' control fire fox with python. Selenium might be worth a look, too: -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-l

Re: STARTTLS extension not supported by server

2010-11-29 Thread Michele Simionato
For future googlers: it turns out in my case the call to .starttls() was not needed: I removed it and everything worked. Dunno why I was there in the first place, the original code was written by somebody else. -- http://mail.python.org/mailman/listinfo/python-list