np.loadtxt for a file with multiple matrices

I have a file that looks something like this: some text the grids are 3 x 3 more text matrix marker 1 1 3 2 4 7 4 2 9 1 1 new matrix 2 4 9 4 1 1 3 4 4 3 1 new matrix 3 3 7 2 1 1 3 4 2 3 2 .. the file continues, with several 3x3 matrices appearing in

while looping at the beginning of the program

I'm trying to create a loop in order to bring the user back to the beginning of the program. I can't get it to print "Welcome to the comparison function". The program will run, asking user for input 1 and 2 and then will print the answer of the

The Oracle date is converted to datetime in python

When i use trunc function in oracle and run the query in oracle developer i get only date value from the datetime field. for eg below query Select trunc(min(Transaction_Date)) as StartDate, trunc(Max(Transaction_Date)) as EndDate from table1 returns

Python - Get the result of Google Search

My goal is to create a small sript that find all the result of a google search but in "raw". I don't speak english very well so i prefer to give an exemple to show you what i would like : I Type : elephant The script return www.elephant.com www.

Installation problem of Dlib for python on Mac OSX 10.10

I'm trying to install dlib-18.16 for python on my computer (running Mac OSX 10.10). I have boost python installed as well as X11, but I've been running into trouble when running ./compile_dlib_python_module.bat as instructed to after downloading the

Modifying paths in Python

I'm trying to create a program that duplicates itself to another location and creates a batch file on the desktop. I can make it duplicate itself and I can create the batch file but I need some help with the paths. I can find the path that my program

Messaging Kombu / Celery

I have a simple application that sends & receives messages, kombu, and uses Celery to task the message. Kombu alon, I can receive the message properly. when I send "Hello", kombu receives "Hello". But when I added the task, what ko

search and replace the line of characters in python

I have a strange case for search and replace a string in text file using python. Input Data: I have a text file which looks similar as shown below. QA1,QBFLUX,1.0 many lines QA2,QBFLUX,1.0 many lines QA3,QBFLUX,1.0 many lines QA4,QBFLUX,1.0 many line

Printing all the files in the shell

The program txt.py prints that takes in a directory as a command line parameter and prints all the files of a particular extension def printAll(path): for txtFile in glob.glob(path): print txtFile printAll(sys.argv[1]) In the command line I type in p

Py.test No module named *

I have a folder structure like this App --App --app.py --Docs --Tests --test_app.py In my test_app.py file, I have a line to import my app module. When I run py.test on the root folder, I get this error about no module named app. How should I configu

The python log unexpectedly prints the indentation

The code is as below: self.class_logg('http://example.com/api/?\ option=ajax&nologin=1&a=vmware_migrate_2&\ original_server_ip=%s&target_server_ip=%s&\ vmware_name=%s' % (self.ip, dest_node.ip, machine.name)) Because this string is so

Pythonic chain manipulation

How can I do the following in a more efficient python friendly way? first_team= re.sub("Northern", "N", first_team) first_team=re.sub("Western", "W", first_team) first_team=re.sub("Southern", "S"

Create a file in the Python subdirectory?

In my Python script, I need to create a new file in a sub directory without changing directories, and I need to continually edit that file from the current directory. My code: os.mkdir(datetime+"-dst") for ip in open("list.txt"): with

Python creates a function to write an object quickly

Hi I'm trying to write a small helper function to save an object to a csv under its own name. I'm working with arrays of data and this is intended to be a workaround to help visualise the array easily to help with editing it. The challenge I'm facing

Python - Can not Import Set from Sets ('no module named sets')

I'm trying to learn python and I was trying to write something simple. I am developing under Pydev (Eclipse) using OS X 10.8. I installed python 3.2 using the 64bits .dmg installer. I configured the Python interpreter successfully (or I think so, as

Extract an element without class attribute

I need to navigate to an html element of a particular type. However, there are many such elements of that type on the page, with many different classes. I need one which does not have any class attribute. Should I look for one with class == '', or is

How to hide the console window for my application?

Possible Duplicate: How can I hide the console window in a PyQt app running on Windows? I've made a simple app that opens a QWebView but in addition to the app window Windows console window is opened to. What could be the reason for this? import sys

import strategy in django apps

I would like to know what is the best import strategy within django reusable applications. Say I have an application called usefulapp. Inside my app, I will need to access, say, the models. Should I use an explicit import as: import usefulapp.models

pyparsing question

This code works: from pyparsing import * zipRE = "\d{5}(?:[-\s]\d{4})?" fooRE = "^\!\s+.*" zipcode = Regex( zipRE ) foo = Regex( fooRE ) query = ( zipcode | foo ) tests = [ "80517", "C6H5OH", "90001-3234",

How to automate the update of a wiki page trac?

I have a trac wiki page I'd like to update automatically on a regular basis (say, once an hour) with data fetched by a script. I can get the script to generate the wiki markup. How would you then upload that to the trac page? I want to replace the wh

Accelerate models in GAE-Py by aggregating RPC calls

Here's my problem: class City(Model): name = StringProperty() class Author(Model): name = StringProperty() city = ReferenceProperty(City) class Post(Model): author = ReferenceProperty(Author) content = StringProperty() The code isn't important... its

PyQt: translate standard buttons

How can I easily translate standard buttons (Yes, No) from QMessageBox? I can't use self.tr on those arguments, so I would like to achieve it in some other simple way. Do I have to use whole translation system?Here is how I did : First you need to co

Can we stop Genshi from analyzing HTML entities?

I have the following Python code using Genshi (simplified): with open(pathToHTMLFile, 'r') as f: template = MarkupTemplate(f.read()) finalPage = template.generate().render('html', doctype = 'html') The source HTML file contains entities such as ©, ™