I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python or Javascript way preferred.
...
How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and pywin32 or wxPython?
Essentially, I need a function that called will return True iff current OS is Vista:
>>> isWindowsVista()
True
...
I have a dict, which I need to pass key/values as keyword arguments.. For example..
d_args = {'kw1': 'value1', 'kw2': 'value2'}
example(**d_args)
This works fine, but if there are values in the d_args dict that are not accepted by the example function, it obviously dies.. Say, if the example function is defined as def example(kw2):
T...
A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir.
Before running 'svn co ...' command in a sub-process ( via python subprocess module ) the parent python code checks if the working copy dir already ex...
Is there a way to describe the module's data (in a similar way that a docstring describes a module or a funcion)?
...
I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me.
I'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they include multiple character e...
Is there any way to access the file object used by a CSV writer/reader object after it has been instantiated? I openned up the csv module, and it appears it's contest are builtin. I also tried setting the file object as a property but I get the following error:
AttributeError: '_csv.writer' object has no attribute 'fileobj'
...
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob?
(I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
...
I've got a file whose format I'm altering via a python script. I have several camel cased strings in this file where I just want to insert a single space before the capital letter - so "WordWordWord" becomes "Word Word Word".
My limited regex experience just stalled out on me - can someone think of a decent regex to do this, or (better...
The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.
...
I want to move a legacy java web application (J2EE) to a scripting language -- any scripting language -- in order to improve programming efficiency.
What is the easiest way to do this? Are there any automated tools that can convert the bulk of the business logic?
...
In many symbolic math systems, such as Matlab or Mathematica, you can use a variable like Ans or % to retrieve the last computed value. Is there a similar facility in the Python shell?
...
I've got a web system where users log in, and it stores a cookie of their session. When they log in as someone else or log out I want to remove that original cookie that I stored. What's the best way to do that?
I'm using Python and Apache, though I suppose the answer will remain the same for most languages.
...
I want to filter two list with any fastest method in python script. I have used built in filter() method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more.
I do not know how I will make it. Please if anybody have idea or write small ...
Hi,
I am trying to setup tracd for the project I am currently working on.
After creating a password file with the python script given in the site I am trying to start the server with authentication on. But it throws up warning saying No users found in the realm. What actually is a realm - I tried using trac as the value and also tried l...
I'm programming (in Python) a website which will have users. These users will have a number of settings, such as their choice of colour scheme, etc. I'm happy to store these as plain text files, and security is not an issue.
The way I currently see it is: there's a dictionary, where all the keys are users and the values are dictionaries...
Using the PHP pack() function, I have converted a string into a binary hex representation:
$string = md5(time); // 32 character length
$packed = pack('H*', $string);
The H* formatting means "Hex string, high nibble first".
To unpack this in PHP, I would simply use the unpack() function with the H* format flag.
How would I unpack thi...
I was playing around with my own Sudoku solver and was looking for some pointers to good and fast design when I came across this:
def r(a):i=a.find('0');~i or exit(a);[m
in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for
j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18]
from sys import*;r(argv[1])
My own implementation solve...
I have a simple website I'm testing. It's running on localhost and I can access it in my web browser. The index page is simply the word "running". urllib.urlopen will successfully read the page but urllib2.urlopen will not. Here's a script which demonstrates the problem (this is the actual script and not a simplification of a differe...
i have the following script
import getopt, sys
opts, args = getopt.getopt(sys.argv[1:], "h:s")
for key,value in opts:
print key, "=>", value
if i name this getopt.py and run it doesn't work as it tries to import itself
is there a way around this, so i can keep this filename but specify on import that i want the standard python li...