python

In the MVC pattern, what goes in the model and what goes in the view?

I'm using the MVC pattern to design some data analysis software (in python). I'm not sure whether some functions should go in the model or the controller. The way I've designed it, the user supplies the program a configuration file which contains the parameters for analysis. The program parses this file to find out what data files to lo...

Run a process and quit without waiting for it

In Python under Windows: I want to run some code in a separate process. And I don't want the parent waiting for it to end. Tried this: from multiprocessing import Process from time import sleep def count_sheeps(number): """Count all them sheeps.""" for sheep in range(number): sleep(1) if __name__ == "__main__": p =...

What do square brackets, "[]", mean in function/class documentation?

I am having trouble figuring out the arguments to csv.dictreader and realized I have no clue what the square brackets signify. From the docmentation: class csv.DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]]) I'd appreciate a summary of the arguments to the class instantiation...

Multiple rows share a value in a column, how do I put all of these rows into one single row?

Hi, I'm working with a text file that looks something like this: rs001 EEE /n rs008 EEE /n rs345 EEE /n rs542 CHG /n re432 CHG /n I want to be able to collapse all of the rows that share the same value in column 2 into one single row (for example, rs001 rs008 rs345 EEE). Is there an easy way to do this using unix text proces...

Python website convert into Adobe Dreamweaver CS3

Comfortable in Adobe Dreamweaver CS3, is there a way to convert a website written in the Python language www.qingdynastyimports.com into Dreamweaver for those who aren't familiar in writing in code? thanks for any comments. ...

javascript error: "data.getElementsByTagName is not a function"

Hi, I've spent hours on this stupid error, so any help would be appreciated! I'm using Jquery to request xml from a python file hosted on google appengine. I'm then trying to process the xml. Here's the response to the post request obtained from firebug: <?xml version="1.0" encoding="ISO-8859-1"?><building key='agdhcHRydXNochALEglCdWl...

Jython exception handling within loops

Hi, I am using Marathon 2.0b4 to automate tests for an application. A shortcoming of wait_p, one of the script elements provided by Marathon, is that its default timeout is hardcoded to be 60 seconds. I needed a larger timeout due to the long loading times in my application. [I considered patching Marathon, but didn't want to maintain ...

Are there database testing tools for python (like sqlunit)?

Are there database testing tools for python (like sqlunit)? I want to test the DAL that is built using sqlalchemy ...

Python decorators and class methods and evaluation -- django memoize

I have a working memoize decorator which uses Django's cache backend to remember the result of a function for a certain amount of time. I am specifically applying this to a class method. My decorator looks like: def memoize(prefix='mysite', timeout=300, keygenfunc=None): # MUST SPECIFY A KEYGENFUNC(args, kwargs) WHICH MUST RETURN A ST...

Python organizing data with multiple dictionaries

I am trying to create a small server type application and have a question regarding organizing data with dicts. Right now I am grouping the data using the connection socket (mainly to verify where it's coming from and for sending data back out). Something like this: connected[socket] = account_data. Basically, each connected person will ...

Euler #26, how to convert rational number to string with better precision?

I want to get 1/7 with better precision, but it got truncated. How can I get better precision when I convert a rational number? Thanks. >>> str(1.0/7)[:50] '0.142857142857' ...

Is there a Python library to handle OWL?

It could be something as big as Jena or something smaller. Do you know anything? ...

Classify array of strings based on commonalities

I have huge list (200000) of strings (multi word). I want to group these strings based on comman array of word match among these strings. I cant think of a low computation time algorithm for this "AB 500" "Bus AB 500" "News CA" "News CA BLAH" My plan was a. Tokenize them to words. b. Create a global array tokens c. Compare those...

Django unit testing - Why can't I just run ./tests.py on myApp?

So I'm very familiar with manage.py test myapp. But I can't figure out how to make my tests.py work as an stand-alone executable. You may be wondering why I would want to do this.. Well I'm working (now) in Eclipse and I can't seem to figure out how to set up the tool to simply run this command. Regardless it would be very nice to sim...

How does pylint quit the Windows command box it is running in?

Pylint is doing something odd on my Windows box - something that shouldn't be possible. This isn't a question about fixing pylint, so much as fixing my understanding. I have a typical install of the latest version of pylint, Python 2.6 and Windows Vista. If I open a Command Prompt, and run pylint from the command line, it executes succ...

Filtering odd numbers

M = [[1,2,3], [4,5,6], [7,8,9]] col2 = [row[1] + 1 for row in M if row[1] % 2 == 0] print (col2) Output: [3, 9] I'm expecting it to filter out the odd numbers, but it does the opposite. ...

Configure "execute shell" scripts in Hudon with Python

I am using Hudson for continuous integration in out project. We are using python, git and nose tests for unit testing. What I need is that Hudson should execute nose tests after every build. For that I have added following shell scripts in under execute shell section. $ nosetests /sub/test_sample1.py $ nosetests /sub/test_sample2.py $ n...

On Windows in python, possibly using the Outlook API, how can I get the full name of a user from their smaller login name?

At work, we have short login names, e.g. hastingsg, but Outlook and I believe other parts of the Windows system also have access to a longer name, e.g. Jeff Hastings. In cpython (not IronPython), if I have the shorter login name, how can I get the longer full name? I have pywin32 and ExchangeCDO installed. ...

What is the Yahoo openid discovery endpoint

It used to be http://yahoo.com, but it is failing for me with DiscoveryFailure in python OpenID library (since today, I wasn't testing this earlier). Also this fails if you try to use the SO login with a yahoo button, so I am thinking it probably changed recently. ...

Diference between appengine_django BaseModel and db.Model

I'm using the Google App Engine helper for Django. This helper includes the following lines in its template: from appengine_django.models import BaseModel from google.appengine.ext import db # Create your models here. Should I derive my models from db.Model or from BaseModel? I've tried both and I don't see any difference. Both seem ...