pywhich script - where is that module?

Discussion in 'Python' started by Keith Dart, Dec 17, 2004.

  1. Keith Dart

    Keith Dart Guest

    Have you ever wondered where your python modules get imported from?
    Here is a little script, called "pywhich", that will tell you.





    --
    \/ \/
    (O O)
    -- --------------------oOOo~(_)~oOOo----------------------------------------
    Keith Dart <>
    public key: ID: F3D288E4
    ============================================================================

    #!/usr/bin/env python

    """pywhich <modname>
    Tell which Python module is imported.
    """

    import sys

    def main(argv):
    if len(argv) < 2:
    print __doc__
    return
    for modname in argv[1:]:
    try:
    mod = __import__(modname)
    except:
    print "No module or package by named '%s' found." % modname
    else:
    print "%15s : %s" % (modname, mod.__file__)

    main(sys.argv)
    Keith Dart, Dec 17, 2004
    #1
    1. Advertising

  2. Am Fri, 17 Dec 2004 09:09:25 +0000 schrieb Keith Dart:

    > Have you ever wondered where your python modules get imported from?
    > Here is a little script, called "pywhich", that will tell you.


    Nice, you could add it to the python cookbook.

    Thomas


    --
    Thomas G├╝ttler, http://www.thomas-guettler.de/
    Thomas Guettler, Dec 17, 2004
    #2
    1. Advertising

  3. Dennis Benzinger, Dec 17, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maric Michaud
    Replies:
    0
    Views:
    7,185
    Maric Michaud
    Jun 24, 2006
  2. Rajat
    Replies:
    3
    Views:
    688
    Jorgen Grahn
    Jan 8, 2010
  3. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    550
    Jan Kaliszewski
    Jan 7, 2010
  4. Billy Mays

    PyWhich

    Billy Mays, Aug 4, 2011, in forum: Python
    Replies:
    11
    Views:
    360
    Steven D'Aprano
    Aug 5, 2011
  5. Bart Van der Donck

    Own module needs loaded module from main script

    Bart Van der Donck, Aug 25, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    126
    Gunnar Hjalmarsson
    Aug 27, 2004
Loading...

Share This Page