Re: [Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-11-28 Thread Kent Johnson
On Sat, Nov 28, 2009 at 6:15 PM, Michael Hannon wrote: > Greetings.  While looking into the use of regular expressions in Python, I > saw that it's possible to name match groups using: > >    (?P...) > > and then refer to them using: > >    (?P=name) > > I was able to get this to work in the foll

Re: [Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-11-28 Thread Martin Walsh
Michael Hannon wrote: > Greetings. While looking into the use of regular expressions in Python, I > saw that it's possible to name match groups using: > > (?P...) > > and then refer to them using: > > (?P=name) I'm not sure you've got that quite right. IIUC, the (?P=name) syntax is us

[Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-11-28 Thread Michael Hannon
Greetings. While looking into the use of regular expressions in Python, I saw that it's possible to name match groups using: (?P...) and then refer to them using: (?P=name) I was able to get this to work in the following, nonsensical, example: >>> x = 'Free Fri Fro From' >>>

Re: [Tutor] Python best practices

2009-11-28 Thread Lie Ryan
On 11/27/2009 7:03 PM, Stefan Lesicnik wrote: hihi! (two in 1 day!) Is there a document, pep, wiki etc that defines best practice for python code? (maybe its more generic). PEP 8 is the official style guideline. I keep stumbling on things I think, it would be nice if someone mentioned thi

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Rich Lovely
2009/11/28 Wayne Werner : > > > On Sat, Nov 28, 2009 at 6:59 AM, Dave Angel wrote: >> >> And if the lists are large, use  itertools.izip() which works the same, >> but produces an iterator. >> >> Note that if the lists are not the same length, I think it stops when the >> shorter one ends. > > But

Re: [Tutor] socket timeout

2009-11-28 Thread Stefan Lesicnik
- "Sander Sweers" wrote: > 2009/11/27 Stefan Lesicnik : > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > #s.setdefaulttimeout(1) > > s.connect((proxy,port)) > > I have never used socket but a quick look at the docs [1] my guess is > that you should use use s.settimeout() [2

[Tutor] glpk

2009-11-28 Thread Robert Johansson
Hi, I would like to use the GNU linear programming kit, preferably with Python and under Windows. After some googling I found python-glpk and ctypes-glpk. The later seems to be an alternative but I get a feeling that the former is the one most people recommend (also, I'm not sure that it will work

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Wayne Werner
On Sat, Nov 28, 2009 at 6:59 AM, Dave Angel wrote: > > And if the lists are large, use itertools.izip() which works the same, but > produces an iterator. > > Note that if the lists are not the same length, I think it stops when the > shorter one ends. > But you can use izip_longest: import ite

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Dave Angel
Jose Amoreira wrote: Hi! I want to process corresponding elements of two lists, sequentially. Call the lists list1 and list2, and assume they have equal lengths. I can do something like for index in range(len(list1)): process(list1[index], list2[index]) But I find it somehow rather ugly,

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Lie Ryan
On 11/28/2009 10:03 PM, Jose Amoreira wrote: Yes, Robert, that does it! Thanks a lot! Have a nice weekend! Jose don't forget zip() built-in function: for x, y in zip(list1, list2): print x, y ___ Tutor maillist - Tutor@python.org To unsubscrib

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Robert Johansson
Hi! I want to process corresponding elements of two lists, sequentially. Call the lists list1 and list2, and assume they have equal lengths. I can do something like for index in range(len(list1)): process(list1[index], list2[index]) But I find it somehow rather ugly, because we generate yet

Re: [Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Jose Amoreira
Yes, Robert, that does it! Thanks a lot! Have a nice weekend! Jose On Saturday 28 November 2009 10:54:56 am Robert Johansson wrote: > Hi! > I want to process corresponding elements of two lists, sequentially. Call > the > lists list1 and list2, and assume they have equal lengths. I can do > someth

[Tutor] Iterating over two sequences in "parallel"

2009-11-28 Thread Jose Amoreira
Hi! I want to process corresponding elements of two lists, sequentially. Call the lists list1 and list2, and assume they have equal lengths. I can do something like for index in range(len(list1)): process(list1[index], list2[index]) But I find it somehow rather ugly, because we generate yet