On 21 May 2007 06:17:16 -0700, dmitrey <[EMAIL PROTECTED]> wrote:
>howto check does module 'asdf' exist (is available for import) or no?
>(without try/cache of course)
>Thx in advance, D.
>

You could use twisted.python.modules:

    $ python
    Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
    [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from twisted.python.modules import getModule
    >>> from sys import modules
    >>> 'Numeric' in modules
    False
    >>> getModule('Numeric')
    PythonModule<'Numeric'>
    >>> 'Numeric' in modules
    False
    >>>

Jean-Paul
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to