Determing source file of a symlink in python
os.path.realpath(symlink)
If you are using the built-in XMLRPCServer or DOCXMLRPCServer in Python on Windows, you may have noticed that you cannot stop the server with a CTRL-C. You have to kill the window! The code below is a derived DOCXMLRPCServer class that works in conjunction with the included ServerWrapper class. The ServerWrapper spins the RPC server [...]
The code below will provide a “cli” for a class instance… For example, if you have a class Car which has a method setDoors(someValue) and an attribute doors which is initialized to 0. When using interactor code saved as interactor.py: import interactor i = interactor.Interact(Car()) > doors 0 > setDoors 5 > doors 5 > [...]
In python, I often use commands.getstatusoutput in unix, however it doesn’t work in windows… here is a function that provides equivalent capability: def commands_getstatusoutput(cmd): from subprocess import Popen, PIPE, STDOUT p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT) output, unused = p.communicate() status = p.returncode return status, output Credit: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f0ff3ca6b89041b3/256b5052fadb0d80?lnk=raot