Re: for ... else ?

2007-06-12 Thread Matthieu TC

> > > On 6/12/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:

> > >> for x in iterable:

> > >>do something with x

> > >> else:

> > >>do something when there are no more x

> >

> > >> You can think the above as:

> >

> > >> while there are still values in iterable:

> > >>do something with the next value

> > >> else:

> > >>do something when there are no more items




Also, if the for loop ends because of a break statement, the else part will 
never be executed..

-mats











-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what is wrong with that r"\"

2007-07-04 Thread Matthieu TC
May I suggest giving the possibility to use any delimiter for a raw string?  
just like in Vi or ruby.

Vi:
 %s_a_b_g  is valid and so is  %s/a/b/g

Ruby:
 %q{dj'\ks'a\'"}   or %q-dj'\ks'a\'"-

So as long as your regex does not use all the valid characters, readability is 
maintained.
-matt


- Original Message 
From: Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, July 4, 2007 9:27:46 PM
Subject: Re: what is wrong with that r"\"

On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote:

> If the escaped quotes didn't function in raw strings, I'd be
> unable to construct (with a single notation) a regex that
> included both kinds of quotes at once.
> 
>   re.compile(r"'\"")

Where's the problem!? ::

  re.compile(r"''')

Ah, I see -- readability is the problem.  :-)

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list



-- 
http://mail.python.org/mailman/listinfo/python-list