Hi.
I have a xml file that I would like to update after it has already data.
I thought about open the xml file in "a" (append) mode. The problem is that the new data will start to be dumped after the "root" tag has been closed.
What I wanted someone to be kind enough to tell me is how can I delete the last line of a file, and then sta...
I have a list. It contains x lists, each with y elements.
I want to pair each element with all the other elements, just once, (a,b = b,a)
EDIT: this has been criticized as being too vague.So I'll describe the history.
My function produces random equations and using genetic techniques, mutates and crossbreeds them, selecting for fitness....
I want to put together simple TCP server using Python and Twisted.
The server starts up and waits for connection - I already have client - non-python application. Once connection is made server starts sending data at some interval (e.g. 1 sec).
The server reads data from a static file (a record at a time), I should be able to figure ou...
Hi Pythoners.
This snippet gets me the dotted quad of my BSD network interface.
I would like to figure out how to use the subprocess module instead.
ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines()
x = string.split(ifcfg_lines[3])[1]
Seems as if I can't use subprocess in exactly the same way.
I don't think I want shell=True ...
Bounty is for the name of a software package for generating tables and running experiments with particular parameters. That is it!
I am running experiments on computer programs with a number of variables whose effect I am measuring. For each run, I record the time, the precision and the recall.
Are there any frameworks that exist that...
I'm primarily a Ruby guy, but lately I've been working on a lot of Python stuff, in particular, App Engine code. In Ruby, I'd use automated continuous integration (autotest), code coverage tools (rcov), static analysis (reek), and mutation testing (heckle) in my development process, but I'm not sure how best to set up a similar developm...
A urllib2 request receives binary response as below:
00 00 00 01 00 04 41 4D 54 44 00 00 00 00 02 41
97 33 33 41 99 5C 29 41 90 3D 71 41 91 D7 0A 47
0F C6 14 00 00 01 16 6A E0 68 80 41 93 B4 05 41
97 1E B8 41 90 7A E1 41 96 8F 57 46 E6 2E 80 00
00 01 16 7A 53 7C 80 FF FF
Its structure is:
DATA, TYPE, DESCRIPTION
00 00 00 01, 4 bytes...
Is there a simple 'wrapper' framework for appengine? Something like Sinatra or Juno? So that one can write code like the following:
from juno import *
@route('/')
def index(web):
return 'Juno says hi'
run()
UPDATE: I want to use the Python API (not Java) in GAE.
...
(I'm developing in Python 3.1, so if there's some shiny new 3.x feature I should know about for this, please let me know!)
I've got a class (we'll just call it "Packet") that serves as the parent for a bunch of child classes representing each of a few dozen packet types in a legacy client-server protocol over which I have no control. (T...
How to convert the following hex string to float (single precision 32-bit) in python?
"41973333" -> 1.88999996185302734375E1
"41995C29" -> 1.91700000762939453125E1
"470FC614" -> 3.6806078125E4
Thanks
...
In my view to render my template I receive different parameters through my request.
According to these parameters I need to render different "part" in my templates.
For example let say that if I receive in my request
to_render = ["table", "bar_chart"]
I want to render a partial template for table and an other for bar_chart
to_rende...
Out of curiosity, are there many compilers out there which target .pyc files?
After a bit of Googling, the only two I can find are:
unholy: why_'s Ruby-to-pyc compiler
Python: The PSF's Python to pyc compiler
So… Are there any more?
(as a side note, I got thinking about this because I want to write a Scheme-to-pyc compiler)
(as a ...
How do you know whether a variable has been set at a particular place in the code at runtime? This is not always obvious because (1) the variable could be conditionally set, and (2) the variable could be conditionally deleted. I'm looking for something like defined() in Perl or isset() in PHP.
if condition:
a = 42
# is a defined he...
I'm writing some code to parse RTF documents, and need to handle the various codepages they can use. Python comes with decoders for all the necessary Windows codepages, but I'm not sure how to handle the Mac ones:
# 77: "10000", # Mac Roman
# 78: "10001", # Mac Shift Jis
# 79: "10003", # Mac Hangul
# 80: "10008", # Mac GB2312
# 81: "100...
Usually I use shell command time. My purpose is to test if data is small, medium, large or very large set, how much time and memory usage will be.
Any tools for linux or just python to do this?
...
If I'm in debug mode, I want to do other stuff than when I'm not.
if DEBUG:
STORED_DATA_FILE = os.path.join(TEMP_DIR, 'store.dat')
LOG_LEVEL = logging.DEBUG
print "debug mode"
else:
STORED_DATA_FILE = os.path.join(SCRIPT_PATH, 'store.dat')
LOG_LEVEL = logging.INFO
print "not debug mode"
then:
python script.py
...
my consumer side of the queue:
m = queue.get()
queue.task_done()
<rest of the program>
questions:
does task_done() effectively pop m off the queue and release whatever locks the consumer has on the queue?
i need to use m during the rest of the program. is it safe, or do i need to copy it before i call task_done()? or, is m usable a...
Hi!
Please regard the following Django models:
ParentModel(models.Model):
...
ChildModel(models.Model):
parent = models.ForeignKey(ParentModel, related_name='children')
Let's assume there is certain subset of all children in the database available as a queryset (call it the 1st set).
Now, I'd like to gain access to the sub...
Hello,
I'm trying to read a csv file but it doesn't work.
I can read my csv file but when I see what I read, there where white space between values.
Here is my code
# -*- coding: iso-8859-1 -*-
import sql_db, tmpl_macros, os
import security, form, common
import csv
class windows_dialect(csv.Dialect):
"""Describe the usual prope...
Hello,
I have a multilingual Django project. Every language is a different subdomain.
So we've decided to use the "sites" application and to create one different site for every language.
On that project, I also have a "pages" application, which is quite similar to a CMS. The user can create pages with content and they'll be displayed i...