On 2014-02-13 10:37, forman.si...@gmail.com wrote:
> I ran across this and I thought there must be a better way of doing
> it, but then after further consideration I wasn't so sure.
> 
> Some possibilities that occurred to me:
> 
>   if key.startswith('<') and key.endswith('>'): ...

This is my favorite because it doesn't break on the empty string like
some of your alternatives.  Your k[0] and k[-1] assume there's at
least one character in the string, otherwise an IndexError is raised.

-tkc




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

Reply via email to