On Apr 17, 9:37 pm, Steven D'Aprano wrote:
> On Sat, 18 Apr 2009 12:37:09 +1200, Lawrence D'Oliveiro wrote:
> > In message ,
> > Steven D'Aprano wrote:
>
> >> BTW, testing for None with == is not recommended, because one day
> >> somebody might pass your function some strange object that compares
On Sat, 18 Apr 2009 12:37:09 +1200, Lawrence D'Oliveiro wrote:
> In message ,
> Steven D'Aprano wrote:
>
>> BTW, testing for None with == is not recommended, because one day
>> somebody might pass your function some strange object that compares
>> equal to None.
>
> Presumably if it compares equ
In message , Steven
D'Aprano wrote:
> BTW, testing for None with == is not recommended, because one day
> somebody might pass your function some strange object that compares equal
> to None.
Presumably if it compares equal to None, that is by design, precisely so it
would work in this way.
--
On Wed, 15 Apr 2009 10:46:28 +0200, Gilles Ganault wrote:
> Since "blocks" is no longer set to None after calling finditer()... but
> doesn't contain a single block... what does it contain then?
It probably took you twenty times more time and effort to ask the
question than it would have to look
On Apr 15, 4:46 pm, Gilles Ganault wrote:
> re_block = re.compile('before (.+?) after',re.I|re.S|re.M)
>
> #Here, get web page and put it into "response"
>
> blocks = None
> blocks = re_block.finditer(response)
> if blocks == None:
> print "No block found"
> else:
> print "Before b
Gilles Ganault wrote:
> I stumbled upon something funny while downloading web pages and
> trying to extract one or more blocks from a page: Even though Python
> seems to return at least one block, it doesn't actually enter the for
> loop:
>
> ==
> re_block = re.compile('before (.+?) a
On Apr 15, 6:46 pm, Gilles Ganault wrote:
> Hello
>
> I stumbled upon something funny while downloading web pages and
> trying to extract one or more blocks from a page: Even though Python
> seems to return at least one block, it doesn't actually enter the for
> loop:
>
> ==
> re_block
On Wed, Apr 15, 2009 at 9:46 AM, Gilles Ganault wrote:
> Hello
>
>I stumbled upon something funny while downloading web pages and
> trying to extract one or more blocks from a page: Even though Python
> seems to return at least one block, it doesn't actually enter the for
> loop:
>
>
Hello
I stumbled upon something funny while downloading web pages and
trying to extract one or more blocks from a page: Even though Python
seems to return at least one block, it doesn't actually enter the for
loop:
==
re_block = re.compile('before (.+?) after',re.I|re.S|re.M)
#Here,