[FAQTS] Python Knowledge Base Update -- June 7th, 2000

Fiona Czuczman fiona at sitegnome.com
Wed Jun 7 13:32:27 EDT 2000


Hi All,

Here are the latest entries into http://python.faqts.com

Cheers,

Fiona Czuczman


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


-------------------------------------------------------------
Why do I get "case mismatch for module name ODBC" errors when using mxODBC?
http://www.faqts.com/knowledge-base/view.phtml/aid/3557
-------------------------------------------------------------
Steve Holden
mxODBC documentation

If you have installed the Windows extentions from the Win32
package developed by Mark Hammond, sometimes confusions arises
between the Win32 odbc.pyd file, usually found in <python>\Lib\Win32,
and the mxODBC distribution, usually found at <python>\Lib\ODBC.

The simplest fix is to rename the odbc.pyd file to Win32odbc.pyd,
although the installation notes for mxODBC do mention a couple of
other approaches.


-------------------------------------------------------------
Is there a way to conditionally pause a loop until some event (button press) takes place?
http://www.faqts.com/knowledge-base/view.phtml/aid/3566
-------------------------------------------------------------
Fiona Czuczman
Ken Seehof

Sounds like you need to use threads.  Read about the 'threading' module.

The idea is that you would run your loop in a separate thread from the 
GUI thread.  This has the additional benefit of keeping your GUI running 
while the loop is running.  When you pause, create a lock which gets 
released when the desired event occurs in the GUI thread..


-------------------------------------------------------------
How can x threads be started at once and stopped y seconds later, processing only the successfully returned threads?
http://www.faqts.com/knowledge-base/view.phtml/aid/3552
-------------------------------------------------------------
Fiona Czuczman
Gordon McMillan

Answer:

Threads have to stop themselves. You can't "kill" a thread without 
jeopardizing the integrity of the process.

For example:

Consider a situation where all the links from multiple URL's must be 
retrieved at the same time. By setting a time limit, slow sites don't 
slow down the whole process and appropriate error messages are returned 
stating which sites weren't completed in y seconds.

Solution:

You need to use a method of retrieving that recognizes time limits. In 
your case, you have 3 choices:

- a version of urllib where urlopen uses select with a timeout and 
aborts  if the timeout expires (Aahz may have done this?).
- a version of urllib that uses non-blocking sockets (then no threads 
needed).
- use separate processes instead of separate threads (because you *can* 
kill a process and properly release resources).

If none of those options are available to you - just ignore the thread 
if it's too slow.


-------------------------------------------------------------
Does Python support multi-threading?
What are the thread and threading modules for?
http://www.faqts.com/knowledge-base/view.phtml/aid/3563
-------------------------------------------------------------
Fiona Czuczman
Thomas Wouters

Yep.  Python does support multi-threading.

Multi-threading :-) the 'thread' module is the low-level thread 
interface, whereas the threading module is a higher-level, more 
object-oriented, Java-inspired (I do believe) interface. Threading is 
fairly basic, however, and not very widely available (partly because not 
all platforms support (proper) threading, and partly because it has to 
be explicitly enabled by whoever compiles Python, on the target machine.


-------------------------------------------------------------
Is there some method similar to seek in the urllib-module?
http://www.faqts.com/knowledge-base/view.phtml/aid/3551
-------------------------------------------------------------
Fiona Czuczman
Robert Roy

>From the documentation for urllib.urlopen(

This supports the following methods: read(), readline(), readlines(),
fileno(), close(), info() and geturl(). 

so no seek()...

nothing preventing you from doing 

x = urlopen('http://www.python.org')
# read into the file and throw away result
x.read(1024)
stuffIWant = x.read(256)


-------------------------------------------------------------
What is wxPython? How does it compare with Tkinter?
http://www.faqts.com/knowledge-base/view.phtml/aid/3565
-------------------------------------------------------------
Fiona Czuczman
Shae Erisson

wxPython is a GUI toolkit that's based on wxWindows:

It's at http://alldunn.com/wxPython/







More information about the Python-list mailing list