Ok so I know the basics of programming languages, I've studied python and liked it a lot. I'm studying now the intermediate parts of python and I'm catching the concepts already. I'm working with a project and at the same time solving computer problems that practices algorithm use. I've learned that python has limitations and wants to co...
My company's web architecture has essentially got an extra layer due to client security requirements, which complicates the process of developing applications a bit. I'd like to get some input and suggestions on the best way to do so.
First, an overview:
presentation layer - this is mostly PHP, with some flex applications as well. We ...
I want to get a list of ints representing the bytes in a string.
...
I'm having some issues importing scapy under jython. I've been doing java forever, but python for only a day or two.
The simple case to reproduce the problem is:
$jython
>>> import sys
>>> sys.path
['', '/usr/share/jython/Lib', '/usr/lib/site-python', '__classpath__']
>>> from scapy.all import *
Traceback (innermost last):
File "<cons...
Possible Duplicate:
What is your solution to the FizzBuzz problem?
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
Here is what I have right...
Hi folks,
I'm using Whoosh and Django-Haystack. I would like to make use of query suggestions for when users mistype words.
e.g. Maybe you meant "unicorn"
Is it necessary to use another search engine? Or can I successfully achieve this with Whoosh?
...
Hi,
I am currently creating my deque object using the following,
self.CommandList = deque((['S', False, 60],['c'],['g16'],['i50'],['r30', True],['u320'],['o5000'],['b1'],['B4500'],['W1'],['l5154'],['!10'],['p2', True, 10],['e1'],['K20'],['U0'],['Y0']))
But I wish to add a similar list to the queue later but using appendleft, so it ca...
Hello, how can I catch the 404 and 403 errors for pages in python and urllib(2), for example?
Are there any fast ways without big class-wrappers?
Added info (stack trace):
Traceback (most recent call last):
File "test.py", line 3, in <module>
page = urllib2.urlopen("http://localhost:4444")
File "/usr/lib/python2.6/urllib2.py",...
Hi Django newbie here,
I have one ip for two domain name, e.g. "www.example.com" and "example.info", and I want each of them to be handled as a different domain (e.g. www.example.com/photos and example.info/photos will be ahndled each by its corresponding function). Is there an elegant way to do this in django?
...
First, some background information: I'm currently developing a program for the Nokia N900 using Python and PyQt4. The program accesses the phone's camera. I have figured out how to use GStreamer in a Qt widget to capture the video. It turns out that I need access to a somewhat obscure gstreamer interface which I don't believe I can ac...
I'm trying to write a script to follow people on twitter. The tweepy API seems pretty good, but I'm running into some unintuitive behavior related to the mapping from user's ids to their screen names.
In [1]: import tweepy
In [2]: api = tweepy.API()
# get an arbitrary tweet
In [3]: tweet = api.search("anything")[0]
In [5]: tweet.text...
Hi,
Could some explain how call back methods work, and if possible, give me an example in Python? So as far as I understand them, they are methods which are provided by the user of an API, to the API, so that the user doesn't have to wait till that particular API function completes. So does the user program continue executing, and once ...
I made a memory mapped file using MemoryMappedFile.CreateNew(mapName, capacity) of .net 4
Can i access this mmf by the mapName from cpython ?
I tried like below.
import mmap
map = mmap.mmap(-1, 0, mapName, 1)
but it returns WindowsError [error 87] saying the parameter is incorrect.
I'm using windows vista.
...
I want to subclass wx.Dialog to get a little more functionality than is provided by the wx.MessageDialog class but I would still like to be able to use the native windows icons (ie the ones used in the wx.MessageDialog that can be set by the flags such as wx.ICON_ERROR etc.. )
Is there anyway to access these?
Update:
Thanks to steven ...
I'm trying to copy files inside a Python script using the following code:
inf,outf = open(ifn,"r"), open(ofn,"w")
outf.write(inf.read())
inf.close()
outf.close()
This works perfectly unedr OSX (and other UNIX flavors I suspect) but fails under Windows. Basically, the read() call returns far less bytes than the actual file size (which ...
i am new to programming need to define operator/function s^m such that
s^m(a^g^n+b^g^o+c^g^p*d^g^q)+a^g^f=a^g^(n+m)+b^g^(o+m)+c^g^(p+m)*d^g^(q+m)+a^g^f
a b c d g ..all symbols ^=power
,in simple language operator which will transform all 'g's in bracket to g^m while keeping those out of bracket as it is .
i am working on solving ...
I make mod_wsgi is like following
$./configure
--with-python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python
--with-apxs=/usr/local/apache2/bin/apxs
checking Apache version... 2.0.63
configure: creating ./config.status
config.status: creating Makefile
$sudo make $sudo make install
and then I cop...
I'm looking for a fast way to interconvert between linear and multidimensional indexing in Numpy.
To make my usage concrete, I have a large collection of N particles, each assigned 5 float values (dimensions) giving an Nx5 array. I then bin each dimension using numpy.digitize with an appropriate choice of bin boundaries to assign each...
I'm trying to define variable inside function. vars() shows variable is created, but gives me NameError: exception. What am I doing wrong?
def a(str1):
vars() [str1] = 1
print vars()
print b
a('b')
output:
{'str1': 'b', 'b': 1}
exception:
NameError: global name 'b' is not defined
...
I am trying to learn how to use threads with python. this is the code I have been studying:
import time
from threading import Thread
def myfunc(i):
print "sleeping 5 sec from thread %d" % i
time.sleep(5)
print "finished sleeping from thread %d" % i
for i in range(10):
t = Thread(target=myfunc, args=(i,))
t.start()
...