I want ro receive some data that is sent as a UDP packet over VPN. So wrote (mostly copied) this program in python:
import socket
import sys
HOST = ???????
PORT = 80
# SOCK_DGRAM is the socket type to use for UDP sockets
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((HOST,PORT))
data,addr = sock.recv(1024)
print...
Hello,
I have a function that has several outputs, all of which "native", i.e. integers and strings. For example, let's say I have a function that analyzes a string, and finds both the number of words and the average length of a word.
In C/C++ I would use @ to pass 2 parameters to the function. In Python I'm not sure what's the right ...
I am trying to use 'py2app' to generate a standalone application from some Python scripts. The Python uses the 'lxml' package, and I've found that I have to specify this explicitly in the setup.py file that 'py2app' uses. However, the resulting application program still won't run on machines that haven't had 'lxml' installed.
My Setup.p...
I'm writing a web app using Python and the web.py framework, and I need to use memcached throughout.
I've been searching the internet trying to find some good documentation on the python-memcached module, but all I could find was this example on the MySQL website, and the documentation on its methods isn't great.
...
On my Google App Engine application, i'm storing an auto-updated date/time in my model like that :
class MyModel(db.Model):
date = db.DateTimeProperty(auto_now_add=True)
But, that date/time is the local time on server, according to it's time zone.
So, when I would like to display it on my web page, how may I format it according th...
Hello,
I would like to generate an HttpResponse that contains a certain string. For each of the characters in the string I have a background color I want to use.
For simplification, let's assume I can only have shades of green in the background, and that the "background colors" data represents "level of brightness" in the green domain...
Hello guys
At work we have Oracle 7. I would like to use python to access the DB.
Has anyone done that or knows how to do it?
I have Windows XP, Python 2.6 and the cx_oracle version for python 2.6
However, when I try to import cx_oracle i get the following error:
ImportError: DLL load failed the module could not be found
Any help is...
The other day I was doing some Python benchmarking and I came across something interesting. Below are two loops that do more or less the same thing. Loop 1 takes about twice as long as loop 2 to execute.
Loop 1:
int i = 0
while i < 100000000:
i += 1
Loop 2:
for n in range(0,100000000):
pass
Why is the first loop so much slow...
I wrote a little function that dynamically defines unittest.TestCase classes (trivial version below).
When I moved it out of the same source file into its own module, I can't figure out how to get unittest to discover the new classes. Calling unittest.main() from either file doesn't execute any tests.
factory.py:
import unittest
_tes...
Earlier today, I asked a question about the way Python handles certain kinds of loops. One of the answers contained disassembled versions of my examples.
I'd like to know more. How can I disassemble my own Python code?
...
I need a little help getting a tar file to download from a website. The website is set up as a form where you pick the file you want and click submit and then the download windows opens up for you to pick the location.
I'm trying to do the same thing in code (so I don't have to manual pick each file). So far I have gotten python 2.5.2 t...
Is this possible:
myList = []
myList[12] = 'a'
myList[22] = 'b'
myList[32] = 'c'
myList[42] = 'd'
When I try, I get:
# IndexError: list assignment index out of range #
...
I am trying to loop from 100 to 0. How do I do this in Python?
for i in range (100,0) doesn't work.
...
I'm trying to use Brandon Walkin's BWSplitView from BWToolkit in a Cocoa PyObjc project. When I run the project I get the following error message:
NSInvalidUnarchiveOperationException - *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (BWSplitView)
Does this mean his toolkit is incompatible with a PyObc proj...
As i write code in python and suddenly feel like adding a new block in front of the code i have already written.... the indentation of the complete code is affected..
it is very tedious process to move to each line and change the indentation...is there any way to do auto indent or something...
eg:
def somefunction:
x =5
retur...
I am coding an application in VB.NET that sends sms.
Would you please post PYTHON->VB.NET
translation of this code and/or guidelines?
Thanks in advance!!!
import threading
class MessageThread(threading.Thread):
def __init__(self,msg,no):
threading.Thread.__init__(self)
self.msg = msg # text message
self.no = no ...
I was able to figure out how to run reports, download files, list folders, etc. on a JasperServer using Python with SOAPpy and xml.dom minidom.
Here's an example execute report request, which works:
repositoryURL = 'http://user@pass:myjasperserver:8080/jasperserver/services/repository'
repositoryWSDL = repositoryURL + '?wsdl'
server = ...
I am trying to read a spreadsheet from app engine using text_db and authsub.
I read http://code.google.com/appengine/articles/gdata.html and got it to work. Then I read http://code.google.com/p/gdata-python-client/wiki/AuthSubWithTextDB and I tried to merge the two in the file below (step4.py) but when I run it locally I get:
Traceback...
I'm using SOAPpy to access a SOAP Webservice. This call to the function findPathwaysByText works just fine:
server.findPathwaysByText (query= 'WP619', species = 'Mus musculus')
However, this call to the function login does not:
server.login (user='amarillion', pass='*****')
Because pass is a reserved word, python won't run this. Is...
I'm starting a small/medium-sized python project, likely in Test Driven Development. My backgrounds are more in C and java than python (I used ant and makefile)
I know that in python you might not need a build tool, but I will, because I'll use cython and PyInstaller (the thing should work on a couple of different UNIXes, without depend...