About Me
CPython - A native port of Python on Windows.
IronPython - An implementation of Python using the .NET environment
CPython - A native port of Python on Windows.
IronPython - An implementation of Python using the .NET environment
CPython - A native port of Python on Windows.
CPython + WinRT??
Where is Windows heading?
Expose Windows specific features
Broad coverage
native IO, services, networking, COM, UI, etc
stable and mature
Leveraged by many other projects;
things like twisted, mercurial etc all take advantage of pywin32 if found.
Downside: fairly large, not easy_install-able
Python has rich cross-platform support - so why target Windows specific features?
But can't all these be done without WMI?
Yes, but only with various low-level API calls.
Which is the fallback if WMI can't do it...
Show all automatic
services which are not running
import wmi c = wmi.WMI() stopped = c.Win32_Service(StartMode="Auto", State="Stopped") for s in stopped: print s.Caption, "service is not running"
from win32service import ( OpenSCManager, EnumServicesStatus, QueryServiceConfig, OpenService, CloseServiceHandle, SC_MANAGER_ENUMERATE_SERVICE, SERVICE_WIN32, SERVICE_INACTIVE, SERVICE_ALL_ACCESS, SERVICE_AUTO_START) hscm = OpenSCManager(None, None, SC_MANAGER_ENUMERATE_SERVICE) for s in EnumServicesStatus(hscm, SERVICE_WIN32, SERVICE_INACTIVE): hs = OpenService(hscm, s[0], SERVICE_ALL_ACCESS) c = QueryServiceConfig(hs) if c[1] == SERVICE_AUTO_START: print name, "is not running" CloseServiceHandle(hs)
PEP 397
'Shebang' processing for Windows
Useful from the command-line too.
Installed with Python 3.3 and available separately
Previously 'last version installed wins'
Python 3.x made this a real problem.
Compatible with *nix shebang lines.
#! /usr/bin/python
#! /usr/bin/env python
Windows specific shebang lines.
#! c:\python27\python.exe
Minimal shebang lines
#! python3
Symlinks are often used on Linux to specify a version.
#! /usr/bin/python3
Launcher handles this too
#! /usr/bin/python3
#! /usr/bin/python2.7
c:\> py script.py
Launches the latest installed Python 2.x - No need for them all to be on the PATH
c:\> py -3.2 script.py
c:\> py -3.3-32 script.py
Launch 3.2, 32bit 3.3
All use of Windows API by core Python uses Unicode
Implementation detail which is completely invisible, but still nice!
os.symlink
might be able to create symbolic links.
os.link
also works with saner semanticsos.kill
does something useful on Windows.
Slightly different semantics and usage than *nix.
RTFM
VirtualEnv is a tool to create isolated Python environments.
Now built into Python itself.
Includes support for Windows
Makes an existing useful tool even more useful!
3.3 uses Microsoft Visual C++ 2010
End to manifest hell
No visible change.
Extension authors must upgrade compiler