Conditionally subclassing based on Import

Discussion in 'Python' started by David Pratt, Oct 3, 2008.

  1. David Pratt

    David Pratt Guest

    Hi, just want to conditionally base a class on another if it can be
    imported, otherwise base it on object. Does the following look ok
    for this?

    except ImportError:
    MyBase =
    MyBase = object

    class Something(MyBase):
    David Pratt, Oct 3, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.