[FAQTS] Python Knowledge Base Update -- July 24th, 2000

Fiona Czuczman fiona at sitegnome.com
Mon Jul 24 03:10:37 EDT 2000


Greetings :-)

Only a couple of new entries into http://python.faqts.com today.

cheers,

Fiona Czuczman

Including:

- Is there a way to get input not echoed to the screen in Python, as in 
the non-standard functions kbhit() and getch() in C and C++?
- How can I change the Proxy Setting in MSIE from python?
- Searching a simple tutorial on the internet for accessing a MySQL 
database using Python.
- Is there any way to shell out to a program and return whatever is 
printed to stdout rather than the exit status?
- Why is my pipe i/o thread blocking the other threads? Any answers?


## Unanswered Questions ########################################


-------------------------------------------------------------
Is there an IPC-modul in Python ?
http://www.faqts.com/knowledge-base/view.phtml/aid/4965
-------------------------------------------------------------
Marc Gehling



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


-------------------------------------------------------------
Is there a way to get input not echoed to the screen in Python, as in the non-standard functions kbhit() and getch() in C and C++?
http://www.faqts.com/knowledge-base/view.phtml/aid/4969
-------------------------------------------------------------
Fiona Czuczman
Bjorn Pettersen

import msvcrt

while not msvcrt.kbhit():
   #do something
c = msvcrt.getch()

assuming you're on windows, of course...


-------------------------------------------------------------
How can I change the Proxy Setting in MSIE from python?
http://www.faqts.com/knowledge-base/view.phtml/aid/4970
-------------------------------------------------------------
Fiona Czuczman
Alex Martelli

This is what MSDN has to say on the issue, after explaining how to find 
out what your usual defaults for proxy are (i.e., Internet 
Options/Connection/Proxy Server):

If you intend to use a proxy other than that named in the dialog box, 
set the AccessType property to icNamedProxy (2). Then set the Proxy 
property to the name of the proxy, as shown in the code below:

Inet1.Proxy = "myProxyName"
Inet1.AccessType = icNamedProxy

On the other hand, if you are content to use the default proxy (as
determined by your computer's registry), ignore the Proxy property, and
simply set the AccessType to icUseDefault (0).

The settings for AccessType are shown in the following table:

Constant     Value           Description
icUseDefault 0 (Default)     Use Defaults. The control uses 
                             default settings found in the
                             registry to access the Internet.
icDirect     1               Direct to Internet. The control has a 
                             direct connection to the Internet.
icNamedProxy 2               Named Proxy. Instructs the control to use 
                             the proxy server specified in the
                             Proxy property.

MSDN mentions this in a Visual Basic context, but of course it should 
all work just as well from Python.

As an aside: being an information junky, I just LOVE the MSDN. Mostly 
for Windows stuff, OK, but I also find it useful as an online searchable 
reference to HTML, the C++ standard library, Unicode character tables, 
etc, etc.  Besides reading it at msdn.microsoft.com, you can probably 
get slightly old extra ones from Windows developer friends for free -- 
MS puts one out 4 times a year, and you don't really need the latest 
one:-).


## Edited Entries ##############################################


-------------------------------------------------------------
Where can I download python DBI for MYSQL?
Searching a simple tutorial on the internet for accessing a MySQL database using Python.
http://www.faqts.com/knowledge-base/view.phtml/aid/3667
-------------------------------------------------------------
Fiona Czuczman
richard_chamberlain,Greg Fortune

To get a MySQL module, go to http://dustman.net/andy/python/MySQLdb/
and download the 0.2.1 release.  The readme included with the module 
will give you a brief description of its functions.  I haven't ever 
tried it on a windows box, but it works great for linux.

Probably best to look at http://www.vex.net/parnassus for most modules. 
They have a nifty tutorial section about lots of python related stuff.


-------------------------------------------------------------
Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status?
http://www.faqts.com/knowledge-base/view.phtml/aid/4922
-------------------------------------------------------------
Loren Poulsen, Michael Hudson, Fiona Czuczman
http://www.python.org/doc/current/lib/module-commands.html,Mark Hammond

import commands
print commands.__doc__

:-)

----------

Use os.popen() - RTFM.  However, note that for Python 1.5.2 and before,
os.popen often doesnt work on Windows - you need my win32 extensions for
this, where win32pipe.popen() does the right thing.  os.popen should
reliably work on Windows in Python 2.0 and later.


-------------------------------------------------------------
Why is my pipe i/o thread blocking the other threads? Any answers?
http://www.faqts.com/knowledge-base/view.phtml/aid/4933
-------------------------------------------------------------
Fiona Czuczman
Richard Brodie

There is a global lock within Python, protecting its internals. When you
call out from a Python to a C extension method in a thread, the thread
holds the lock.

For maximum parallelism, and particularly if you're doing blocking I/O
in a thread, you need to release and reaquire the lock.

See: http://www.python.org/doc/current/api/threads.html for details.

------------

This is only a solution if the problem occurs when using a non-standard 
extension module (ie, a Python module implemented in C/C++).  The 
statement "you need to release and reaquire the lock" is misleading - 
you can _not_ do this from Python code - only C code can do this.


-------------------------------------------------------------
Is there any way I can prevent pythonwin(scintilla) from reading the method names of a specific class
http://www.faqts.com/knowledge-base/view.phtml/aid/4734
-------------------------------------------------------------
Nils Otto Johansen, Fiona Czuczman
Mark Hammond

NO.







More information about the Python-list mailing list