list index()

zzbbaadd at aol.com zzbbaadd at aol.com
Thu Aug 30 23:06:38 EDT 2007


On Aug 30, 4:48 pm, "Chris Mellon" <arka... at gmail.com> wrote:
> On 8/30/07, zzbba... at aol.com <zzbba... at aol.com> wrote:
>
>
>
> > On Aug 30, 4:31 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
> > wrote:
> > > zzbba... at aol.com writes:
> > > > In my case of have done os.listdir() on two directories. I want to see
> > > > what files are in directory A that are not in directory B.
>
> > > You get that information unambiguously. It's an exceptional case,
> > > since there's no index to return, so it throws an exception.
>
> > > > I have used exceptions in other languages and only do so on logic
> > > > that should never happen.
>
> > > You're confusing "assert" ("this should always be true") with
> > > "exception" ("this is an exception to the the normal flow of this
> > > process").
>
> > > An exception isn't "something that should never happen", it's
> > > something that is entirely possible and needs to be handled somehow.
>
> > I don't think that is the definition used across computer science.
>
> how its defined in Python is what is important in this context.

Is there a definition on python.org for an exception?

>
> > It suddenly dawned on me that what would be best would be a contains()
> > (or IN syntax for those who can't afford to wait) for lists.
>
> > if mylist.contains("hello):
>
> Genius. Why didn't anyone think of that before?

With an attitude like that Chris, don't expect to be getting an invite
to beta test my Python 3 fork.




More information about the Python-list mailing list