I want to use Python to make a configuration file generator. My roughly idea is feeding input with template files and some XML files with the real settings. Then use the program to generate the real configuration files.
Example:
[template file]
server_IP = %serverip%
server_name = %servername%
[XML file]
<serverinfo>
<server ip="x....
I need to make credit card payments on my site that provides a service outside the U.S., but I will not be through paypal, where should I start? anyone knows how I can do this?
...
i have these 2 functions i got from some other code
def ROR(x, n):
mask = (2L**n) - 1
mask_bits = x & mask
return (x >> n) | (mask_bits << (32 - n))
def ROL(x, n):
return ROR(x, 32 - n)
and i wanted to use them in a program, where 16 bit rotations are required. however, there are also other functions that require 32 b...
If possible I would like to use the following structure for a command however I can't seem to figure out how to achieve this in Python:
./somescript.py arg <optional argument> -- "some long argument"
Would it be possible to achieve this in a feasible manner without too much dirty code? Or should I just reconsider the syntax (which is p...
One of my django models has a large TextField which I often don't need to use. Is there a way to tell django to "lazy-load" this field? i.e. not to bother pulling it from the database unless I explicitly ask for it. I'm wasting a lot of memory and bandwidth pulling this TextField into python every time I refer to these objects.
The al...
Hi, I need a data structure for doing 2d range counting queries (i.e. how many points are in a given rectangle).
I think my best bet is range tree (it can count in log^2, or even log after some optimizations). Does it sound like a good choice? Does anybody know about a python implementation or will I have to write one myself?
...
I can't understand why I am loosing control of my GUI even though I am implementing a thread to play a .wav file. Can someone pin point what is incorrect?
#!/usr/bin/env python
import wx, pyaudio, wave, easygui, thread, time, os, sys, traceback, threading
import wx.lib.delayedresult as inbg
isPaused = False
isStopped = False
clas...
Hi, I new using python + webkit.
I need make a POST request with webkit, but I dont know how to it.
I use python-webkit because my app load a form on the GUI (for vote, comments and send more data) and I need post all these data with a POST request and load the html result send for the server to my GUI app with python-webkit.
I have o...
EDIT 1
Hmm, I accept the answers that tar respects an empty file... but on my system:
$ touch emptytar
$ tar -tf emptytar
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
Maybe I have a non-canonical version?
$ tar --version
tar (GNU tar) 1.22
Copyright (C) 2009 Free Software Founda...
I would like to get user input to refer to some list in my code. I think it's called namespace? So, what would I have to do to this code for me to print whatever the user inputs, supposing they input 'list1' or 'list2'?
list1 = ['cat', 'dog', 'juice']
list2 = ['skunk', 'bats', 'pogo stick']
x = raw_input('which list would you like me t...
Hi lads,
After obtaining the urls for various blogspots, tumblr and wordpress pages, I faced some problems processing the html pages. The thing is, i wish to distinguish between the content,title and date for each blog post. I might be able to get the date through regex, but there are so many custom scripts people are using now that the...
Hi,
The following example shows what I want to do:
>>> test
rec.array([(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
dtype=[('ifAction', '|i1'), ('ifDocu', '|i1'), ('ifComedy', '|i1')])
>>> test[['ifAction', 'ifDocu']][0]
(0, 0)
>>> test[['ifAction', 'ifDocu']][0]...
In 2.6, if I needed to accept input that allowed a percent sign (such as "foo % bar"), I used raw_input() which worked as expected.
In 3.0, input() accomplishes that same (with raw_input() having left the building).
As an exercise, I'm hoping that I can have a backward-compatible version that will work with both 2.6 and 3.0.
When I us...
how do i represent binary search trees in python?
...
I am trying to put together a bash or python script to play with the facebook graph API. Using the API looks simple, but I'm having trouble setting up curl in my bash script to call authorize and access_token. Does anyone have a working example?
...
I am working on a major project that I need for work. I am working on a project that requires software validation. I would like this to be handled by a custom server I will write in Python, this server will be the "gateway" between the user and product activation.
The software program will be purchased from other companies in volume li...
Hi,
I have two processes.
One processes is redirecting output of some unix command to a file on server side.The data is always appended to the file. e.g.
find / > tmp.txt
Another process is opening and reading the same file and storing it in a string and sending the entire string to the client.
Now, this things take simultaneously...
I have an XML document which reads like this:
<xml>
<web:Web>
<web:Total>4000</web:Total>
<web:Offset>0</web:Offset>
</web:Web>
</xml>
my question is how do I access them using a library like BeautifulSoup in python?
xmlDom.web["Web"].Total ? does not work?
...
import socket, sys
if len(sys.argv) !=3 :
print "Usage: ./supabot.py <host> <port>"
sys.exit(1)
irc = sys.argv[1]
port = int(sys.argv[2])
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((irc, port))
sck.send('NICK supaBOT\r\n')
sck.send('USER supaBOT supaBOT supaBOT :supaBOT Script\r\n')
sck.send('JOIN #darkundergro...
i want to know how to get wav samples out of a wav file for performing windowed join of two wave files.
can any one please tell how to do this???
...