I have created an XML file using python. But the XML declaration has only version info. How can I include encoding with XML declaration like:
<?xml version="1.0" encoding="UTF-8"?>
I want to be able to read events from a MIDI file in Python. I have looked for libraries, but can't find one that works with my MIDI file in windows. I do not need to do anything real time, and just want a simple library that gives me events and times. Would it be easier to write one for myself? Any help would be appreciated.
There are times that I automagically create small shell scripts from Python, and I want to make sure that the filename arguments do not contain non-escaped special characters. I've rolled my own solution, that I will provide as an answer, but I am almost certain I've seen such a function lost somewhere in the standard library. By “lost” I mean I didn't find it in an obvious module like shlex, cmd or subprocess.
Do you know of such a function in the stdlib?
I have an RRD database, and I want to parse some of the data in it. I found this:
http://pypi.python.org/pypi/PyRRD/0.0.7
but it basically just calls the command line tools (no parsing).
Does anyone know of a library that will actually parse the output of rrdtool dump?
Thanks!
Is there a way to get the ceil of a high precision Decimal in python?
>>> import decimal;
>>> decimal.Decimal(800000000000000000001)/100000000000000000000
Decimal('8.00000000000000000001')
>>> math.ceil(decimal.Decimal(800000000000000000001)/100000000000000000000)
8.0
math rounds the value and returns non precise value
Hi folks,
Can anyone help me out in fitting a gamma distribution in python? Well, I've got some data : X and Y coordinates, and I want to find the gamma parameters that fit this distribution... In the Scipy doc, it turns out that a fit method actually exists but I don't know how to use it :s.. first, in wich format the argument "data" must be, and how can I provide the seconde argument (the parameters) since this what I'm looking for ???
Thanks a lot!
I'd like to iterate over a list in Python several (say, 10) elements at a time, processing each slice one by one. I can think of a few ways to do this, but none seems obvious and clean. What is the most Pythonic way to do this?
I have a custom module in one of the directories in my PYTHONPATH with the same name as one of the standard library modules, so that when I import module_name, that module gets loaded. If I want to use the original standard library module, is there any way to force Python to import from the standard library rather than from the PYTHONPATH directory, short of renaming the custom module and changing every reference to point to the new name?
On Linux, how can I find the default gateway for a local ip address/interface using python?
I saw the question "How to get internal IP, external IP and default gateway for UPnP", but the accepted solution only shows how to get the local IP address for a network interface on windows.
Thanks.
Hi there,
I'm currently aware of the following Python JIT compilers: Psyco, PyPy and Unladen Swallow.
Basically, I'd like to ask for your personal experiences on the strengths and weaknesses of these compilers - and if there are any others worth looking into.
Thanks in advance,
Az
Hi,
My requirement is to search for jpeg images files in a directory using python script and list the file names. Can anyone help me on how to identify jpeg images files.
Thanks in advance...
How might one extract all images from a pdf document, at native resolution and format? (Meaning extract tiff as tiff, jpeg as jpeg, etc. and without resampling). Layout is unimportant, I don't care were the source image is located on the page.
I'm using python 2.6 but can use 3.x if required.
thanks
What is the best way of doing this in Python?
for (v = n / 2 - 1; v >= 0; v--)
I actually tried Google first, but as far as I can see the only solution would be to use while.
This might be a really dumb question, however i've looked around online, etc. And have not seen a solid answer.
What i was wondering, is there a simple way to do something like this?
lines = open('something.txt', 'r').readlines()
for line in lines:
if line == '!':
# force iteration forward twice
line.next().next()
<etc>
Is there an easy way to do that in python?
Hi everyone, I am trying to run a python script through an application I've written. I found some pages which say that this piece of code is doing it, but I can't figure it out.
http://code.google.com/p/android-scripting/source/browse/android/AndroidScriptingEnvironment/src/com/google/ase/locale/LocaleReceiver.java
Can someone explain what is going on and how I can edit that to run an arbitrary script file in my project directory?
I have a Python function that gives back some read-write buffer:
>>> x = h.GetEXlow()
>>> x
<read-write buffer ptr 0xa2b8140, size 2147483647 at 0x8b73f80>
Now I would like to memset the whole buffer content to zero. (The size stated above is obviously wrong, but I can determine the size without problems.) How do I do this?
I am running ipython from sage and also am using some packages that aren't in sage (lxml, argparse) which are installed in my home directory. I have therefore ended up with a $PYTHONPATH of
$HOME/sage/local/lib/python:$HOME/lib/python
Python is reading and processing the first easy-install.pth it finds ($HOME/sage/local/lib/python/site-packages/easy-install.pth) but not the second, so eggs installed in $HOME/lib/python aren't added to the path. On reading the off-the-shelf site.py, I cannot for the life of me see why it's doing this.
Can someone enlighten me? Or advise how to nudge Python into reading both easy-install.pth files?
Consolidating both into one .pth file is a viable workaround for now, so this question is mostly for curiosity value.
How would I convert test cases made by Selenium IDE to Python without exporting every test case by hand? Is there any command line converter for that job?
In the end I want to use Selenium RC and Pythons build in unittest to test my websites.
Thanks a lot.
What tools are available in Python to assist in parsing a context-free grammar?
Of course it is possible to roll my own, but I am looking for a generic tool that can generate a parser for a given CFG.
I have an App Engine app written in Google's webapp framework and I want to add some credit card handling to it.
Does a library already exist to integrate payment processing into an App Engine Python app?
I want to memcache an xmldata using python,also needs to update the cache with the refreshed xmldata retreived from webserver,could any one help me with sample code.
Looking to put together a 3D side-scrolling action platformer. Since this is my first time trying to put together a non-simple adventure game, I'm at a loss for which engine to consider.
I would prefer one that supports scripting in python, since that's my primary language. Without tight controls, the game will suck... so speed is a priority. Cross-platform is also important to me.
Any suggestions?