[FAQTS] Python Knowledge Base Update -- May 27th, 2000

Fiona Czuczman fiona at sitegnome.com
Sat May 27 09:54:39 EDT 2000


Hi Guys,

Below are the entries I've entered into http://python.faqts.com

cheers,

Fiona Czuczman


## New Entries #################################################


-------------------------------------------------------------
How can I reload things imported with 'from HUGO import *'?
http://www.faqts.com/knowledge-base/view.phtml/aid/3281
-------------------------------------------------------------
Fiona Czuczman
Michael Hudson

import HUGO
reload(HUGO)
from HUGO import *

or

reload(sys.modules["HUGO"]); from HUGO import *

(another reason not to use "import *"...)


-------------------------------------------------------------
Is there anyway I can get the traceback on to the web page so I know what's happening?
http://www.faqts.com/knowledge-base/view.phtml/aid/3282
-------------------------------------------------------------
Fiona Czuczman
Fredrik Lundh, David Currie

The easiest way is to split your CGI module in two parts; use the 
following script as a wrapper, and place the program logic in a separate 
script ("my-script.main()" in this case):

#!/usr/bin/env python

import cgi, StringIO, sys, traceback

try:
    import myscript
    myscript.main()
except:
    print "Content-Type:", "text/html"
    print
    file = StringIO.StringIO()
    traceback.print_exc(file=file)
    print "<pre>"
    print cgi.escape(file.getvalue())
    print "</pre>"

If there is an error while running the program it will be displayed.
If the traceback does not appear in the result, then chances are you
have a syntax error in your code.  Set a debug mode that allows you to
run the script locally without calling cgi.FieldStorage() and related
stuff, and this should help you debug these errors.


-------------------------------------------------------------
Is there a function returning the intersection of two lists?
http://www.faqts.com/knowledge-base/view.phtml/aid/3283
-------------------------------------------------------------
Fiona Czuczman
Penfold

Example:

l1 = [1,2,3,4,5]
l2 = [4,5,6,7,8]

l3 should be [4,5]

Solution:

You could try using the ever useful kjbuckets module (find it on
http://www.vex.net/parnassus).

This implements mathematical sets and graphs which mean your below 
becomes as easy as

kjSet([1,2,3,4,5]) & kjSet([4,5,6,7,8])


-------------------------------------------------------------
Where can I find information (code, hints...) about Python and Interbase?
http://www.faqts.com/knowledge-base/view.phtml/aid/3260
-------------------------------------------------------------
Fiona Czuczman
Anders M Eriksson

Mr Alexander Kuznetsov is maintaining a thing called kinterbasdb which
is an interface between Python and Interbase.

You'll find it at: http://www.python.org/topics/database/modules.html







More information about the Python-list mailing list