nested exceptions?

Nick Arnett narnett at mccmedia.com
Sun Apr 21 11:08:08 EDT 2002


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Aahz

...

> That is, if you're checking N items against a list with M items, you're
> gonna have poor performance algorithmically.  Note that I said "avoid";
> using 'in' against a list is sometimes the simplest and most
> straightforward approach, and if it's not being done in a loop, it won't
> cause too much of a performance hit.

So... although the following is such a short list that I don't think it
really matters (except that, come to think of it, it is in a loop), it's bad
form?

if self.item[0:3] in ('Mon','Tue','Wed','Thu','Fri','Sat','Sun'):
	self.item = self.item[4:]

If it's not obvious, this is stripping the day abbreviation from the
beginning of a timestamp that I'm converting to another format.

I can't quite see how to use "while... not" to do what I want, however.

Nick






More information about the Python-list mailing list