Skip to content
Advertisement

Getting HTTP GET arguments in Python

I’m trying to run an Icecast stream using a simple Python script to pick a random song from the list of songs on the server. I’m looking to add a voting/request interface, and my host allows use of python to serve webpages through CGI. However, I’m getting hung up on just how to get the GET arguments supplied by the

Python Regular Expression Match All 5 Digit Numbers but None Larger

I’m attempting to string match 5-digit coupon codes spread throughout a HTML web page. For example, 53232, 21032, 40021 etc… I can handle the simpler case of any string of 5 digits with [0-9]{5}, though this also matches 6, 7, 8… n digit numbers. Can someone please suggest how I would modify this regular expression to match only 5 digit

How do I know what python scripts are running in Windows?

As I mentioned above, is there a way to find out what python scripts are running in Windows? Answer If you have PowerShell installed, you can get that information by using Windows Management Instrumentation (WMI) and some scripting… Open the PowerShell and use these two lines, it should could you started: This will show you the command line arguments used

Run Process and Don’t Wait

I’d like to run a process and not wait for it to return. I’ve tried spawn with P_NOWAIT and subprocess like this: However, the console window remains until I close Notepad. Is it possible to launch the process and not wait for it to complete? Answer This call doesn’t wait for the child process to terminate (on Linux). Don’t ask

How to completely remove Python from a Windows machine?

I installed both Python 2.7 and Python 2.6.5. I don’t know what went wrong, but nothing related to Python seems to work any more. e.g. “setup.py install” for certain packages don’t recognize the “install” parameter and other odd phenomena… I would like to completely remove Python from my system. I tried running the 2.7 and 2.6 msi files and choosing

How to sum dict elements

In Python, I have list of dicts: I want one final dict that will contain the sum of all dicts. I.e the result will be: {‘a’:5, ‘b’:7} N.B: every dict in the list will contain same number of key, value pairs. Answer A little ugly, but a one-liner:

How can I get a human-readable timezone name in Python?

In a Python project I’m working on, I’d like to be able to get a “human-readable” timezone name of the form America/New_York, corresponding to the system local timezone, to display to the user. Every piece of code I’ve seen that accesses timezone information only returns either a numeric offset (-0400) or a letter code (EDT) or sometimes both. Is there

Advertisement