Python vs. Perl, which is better to learn?
Alex Martelli
aleax at aleax.it
Wed May 1 08:29:29 EDT 2002
Andrew Dalke wrote:
...
>> unPythonic arrangement -- the upper bound is *included* (Python's ranges,
>> slices etc have lower-bound-included, upper-bound-excluded...).
>
> But it isn't a range, it's a repeat count. Otherwise people would
> also expect
>
> ^a{0}
>
> to match "" because that contains 0 "a"s. As such, it's much more
"Otherwise"...?
>>> a0=re.compile('^a{0}')
>>> a0.match('')
<_sre.SRE_Match object at 0x8187fb0>
Of *course* a{0} matches '' -- how could it FAIL to?
Alex
More information about the Python-list
mailing list