"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:

> stef mientki schrieb:
> > What should I do to the same simple test for existance ?
> 
> Use isinstance(obj, type).

No, that's *far* more specific than "does it exist", and will give
false negatives.

Much better is::

    foo = None
    foo = do_something_to_get_instance()
    # ...
    if foo is not None:
        # foo was bound to an instance correctly

Even better is just to use the object, and if it's not what was
expected, catch the exception at a level that knows what to do about
it.

-- 
 \      "At my lemonade stand I used to give the first glass away free |
  `\          and charge five dollars for the second glass. The refill |
_o__)                         contained the antidote."  -- Emo Philips |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to