converting from perl: variable sized unpack
Quinn Dunkan
quinn at yak.ugcs.caltech.edu
Mon Jul 16 13:13:05 EDT 2001
On Mon, 16 Jul 2001 14:12:52 +0200, Alex Martelli <aleaxit at yahoo.com> wrote:
>"Roy Smith" <roy at panix.com> wrote in message
>news:roy-E01423.21425015072001 at news1.panix.com...
>> quinn at yak.ugcs.caltech.edu (Quinn Dunkan) wrote:
>> > Even without that, I argue that a bad pattern match should throw an
>> > exception and not assign None
>>
>> I have to admit, that would be somewhat consistant with the way the rest
>of
>> the language works, but it sure would make it more complicated to do
>> something like:
>>
>> if re.match (pattern1, string):
>> do stuff
Oops, note that I wasn't talking about regular expressions when I said
"pattern match". The terminology is a holdover from some other languages. I
should get in the habit of using the python terminology: sequence unpacking.
And I'm perfectly happy that failed regular expressions don't raise. A
failing regexp is not an exceptional situation---it's normal and expected and
intended. It would be pretty annoying to have to wrap up every re.search in
try/except.
More information about the Python-list
mailing list