[FAQTS] Python Knowledge Base Update -- July 15th, 2000
Fiona Czuczman
fiona at sitegnome.com
Sat Jul 15 21:08:20 EDT 2000
Hi List,
Here are the latest entries into http://python.faqts.com
cheers,
Fiona
## Unanswered Questions ########################################
-------------------------------------------------------------
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
## New Entries #################################################
-------------------------------------------------------------
Where can I find a DB-API connection to Sybase?
http://www.faqts.com/knowledge-base/view.phtml/aid/4753
-------------------------------------------------------------
Fiona Czuczman
Paul Boddie
The 'ctsybasemodule' apparently resides at the following URL:
http://starship.python.net/crew/pgodman/
Whilst 'ctsybasemodule' is rather nice, I found it insufficient for my
purposes (no "bind variables" in SQL statements) and decided on mxODBC
instead:
http://starship.python.net/crew/lemburg/mxODBC.html
If you decide to pursue that option, I would suggest looking at my ODBC
resources page:
http://www.crosswinds.net/~pboddie/Python/mxODBC.html
I managed to get mxODBC working with Adaptive Server Anywhere and
Adaptive Server Enterprise, but with the recent announcement of zxJDBC
you could use JPython and Sybase's jConnect software instead:
http://www.ziclix.com/zxjdbc/
http://www.jpython.org
http://www.sybase.com/products/internet/jconnect/
-------------------------------------------------------------
How can I call an .exe file from inside a .py file?
http://www.faqts.com/knowledge-base/view.phtml/aid/4757
-------------------------------------------------------------
Fiona Czuczman
Alex Shindich, Gregoire Welraeds
Try this:
import os
os.execl ('foo.exe')
For more info read http://www.python.org/doc/current/lib/os-process.html
execl is kind of an alias for execv. So using this solution, be aware of
the following:
execv (path, args)
Execute the executable path with argument list args, replacing the
current process (i.e., the Python interpreter). The argument list may be
a tuple or list of strings. Availability: Unix, Windows.
This mean that if you have the following code in a file:
import os
os.execv("/bin/ls",("ls","/"))
print "Done!"
The last line will never be executed because the python process is
replaced by the /bin/ls command. To avoid this, Unix allows you to use
the fork system call :
import os
i= os.fork()
if i != 0:
os.waitpid(i,0) # wait for the child to complete.
print done!
else: # child process
os.execv("/bin/ls",("ls","/"))
Another and easier solution, which also works under Windows :
import os
os.system("foo.exe")
print 'Done!'
## Edited Entries ##############################################
-------------------------------------------------------------
How can you check on the status of a file's "archive" bit, on DOS-type platforms
http://www.faqts.com/knowledge-base/view.phtml/aid/4706
-------------------------------------------------------------
Barry Pederson, Fiona Czuczman
http://www.python.org/windows/win32all/,Alex Martelli
On Win32, with Hammond's extensions:
PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on
win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au)
>>> from win32file import GetFileAttributes
>>> GetFileAttributes("C:/witha.txt")
32
>>> GetFileAttributes("C:/withouta.txt")
128
>>>
where witha.txt does have the A attribute and withouta.txt lacks it.
You can also use symbolic names for the constants:
>>> import win32file
>>> win32file.FILE_ATTRIBUTE_ARCHIVE
32
>>> win32file.FILE_ATTRIBUTE_NORMAL
128
>>>
Note that the 'normal' bits seems to be set if and only if no other
bits are set. Other attributes in the bitmask behave more normally,
i.e., they are bitwise-or'ed to give all attributes of the file.
For example, after making witha.txt read-only (still _with_ the A
attribute as well), we have:
>>> GetFileAttributes("C:/witha.txt")
33
>>> win32file.FILE_ATTRIBUTE_READONLY
1
>>>
I.e., the attributes of the file are the bitwise-or of archive and
readonly. So, if you only want to test for archive, and don't care
about the others, you'll bitwise-and GetFileAttributes' result with
FILE_ATTRIBUTE_ARCHIVE, rather than testing for equality!
More information about the Python-list
mailing list