What's with the index() function of lists throwing an exception on not
found? Let's hope this is rectified in Python 3. If nothing else, add
a function that doesn't throw an exception. There are a million
situations where you can have an item not be in a list and it is not
an exception situation.
On Aug 30, 12:09 am, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > What's with the index() function of lists throwing an exception on not
> > found?
>
> It's letting you know that the item isn't in the list. There's no
> sensible return value from an "index" function in that
>
> How could it not be an exception, in the plain English sense of the
> word? Most certainly you're asking for the index because you want to do
> something with the index. If the item is not found, you have no index,
> so that's a special case that must be handled separately. There is no
> logica
On Aug 30, 12:42 am, Bruno Desthuilliers wrote:
> [EMAIL PROTECTED] a écrit :
>
> What's with using your brain instead of whining ?
I knew there would be at least one religious zealot.
--
http://mail.python.org/mailman/listinfo/python-list
> While I agree that Bruno's response was perhaps needlessly snippy, your
> original question was needlessly inflammatory, as if you somehow wanted
> some "religious zealot" to act the way Bruno did. If we start labeling
> people, this thread will earn you a label that rhymes with "roll".
>
That is
Neil, Steve,
Thanks for the responses on sets. I have not used them before and was
not even aware Python had them. I will try them out.
--
http://mail.python.org/mailman/listinfo/python-list
> That wish will only come true if you maintain your own fork of Python 3.
> has_key() will go away, period. It has been made obsolete by "in", which
> is faster and more concise.
Is there really some reason "key" IN dict can be implemented faster
than dict.has_key("key")???
--
http://mail.p
I have read that you can derive from the base classes such as str,
list, dict.
I guess this would look like:
def MyString(str):
def MyList(list):
def MyDict(dict):
How do you access the data that is contained in the super class?
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 30, 12:13 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Aug 30, 8:00 pm, [EMAIL PROTECTED] wrote:
>
> > I have read that you can derive from the base classes such as str,
> > list, dict.
>
> > I guess this would look like:
>
> > def MyString(str):
> > def MyList(list):
> > def MyDict(
On Aug 30, 12:18 pm, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I have read that you can derive from the base classes such as str,
> > list, dict.
>
> > I guess this would look like:
>
> > def MyString(str):
> > def MyList(list):
> > def MyDict(dict):
>
> Well,
On Aug 30, 4:28 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] writes:
> > On Aug 30, 12:09 am, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> > > It's letting you know that the item isn't in the list. There's no
> > > sensible return value from an "index" function in that condition.
>
On Aug 30, 4:31 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] 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,
> sin
On Aug 30, 4:48 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 8/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 30, 4:31 pm, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> > > [EMAIL PROTECTED] writes:
> > > > In my case of have done os.listdir() on two directories. I want to
> Either I'm misunderstanding what you mean or you need to get a clue
> about what Python can already do before you go around making suggestions
> for what Python needs. Lists have supported "in" tests since at least
> version 1.5.2:
>
Well IN was what I was looking for and would have saved this t
14 matches
Mail list logo