2 answers

Issues finding average of a list and its sublists

I can't seem to figure out why my averages in the code below are wrong when I use a mix of positive and negative numbers. any help is greatly appreciated, thanks in advance. my_num = [] while True: ...

2 answers | 15 secs ago by qaguy on Stack Overflow stackoverflow.com
0 answers

Read in audio stream from computer audio

I am looking to detect when a specific sound is played through a specific device. I know the first step would be to have a way to read in the audio that is currently being played, and then compare to ...

0 answers

How to run pyramid application with uwsgi?

Have a pyramid application and want to run it with uwsgi. I have ini file with the following uwsgi section: [uwsgi] socket = /tmp/uwsgi.sock master = true processes = 4 harakiri = 60 harakiri-verbose ...

0 answers

Subtracing float from a datetime in Pandas (numpy)

How do I subtract the float values in vectorized form from a datetime64 array? Data: import numpy as np import pandas as pd some_dates = np.array(['2007-07-13', '2006-01-13', '2010-08-13'], ...

1 answer

How to import some set of Python modules globally?

In my particular setting, I have a set of python modules that include auxiliary functions used in many different other modules. I putted them into a LIBS folder and I have other folder at the same ...

1 answer

Getting all the lines inbetween two strings and storing the data in another file in python 2.7

I am trying to implement a method to find all the lines in between two strings for example Jan 01 01:25:08 AMIRA-134500021 user.notice gui-monitor[770]: ACTION:401b0836:8:PAGE(leave) ...

0 answers

cursor hangs in oracle using python and cx_oracle

My cursor appears to hang at a the same row when I do a fetchmany in a loop. I'm using Python, and the cx_oracle rows = cur.fetchmany(100) count = 0 while rows: count += len(rows) print count ...

0 answers

File access blocking in python thread

I want to implement a class in python to watching a file's modification, and I use os.path.getmtime to get the modification time. If I'm editing file test.txt, os.path.getmtime('test.txt') works ...

0 answers

how to surround selected text in PyCharm like with sublim text

I'm wondering if there is a way to configure PyCharm to be able to surround selected code with parenthesis by just typing on the parenthesis key like when we use SublimText 2. Thanks.

1 answer

Schematron validation with lxml in Python: how to retrieve validation errors?

I'm trying to do some Schematron validation with lxml. For the specific application I'm working at, it's important that any tests that failed the validation are reported back. The lxml documentation ...

0 answers

Google App Engine Cache Time

I read xml files off other servers via: urllib2.urlopen(url) Does Google App Engine load the url every time the page is requested or does it cache it for some time? How long does it store the ...

10 answers

Python string formatting: % vs. .format

Python 2.6 introduced the str.format() method with a slightly different syntax from the existing % operator. Which is better and for what situations? The following uses each method and has the same ...

1 answer

Is this actually using threading to scrape for urls?

Thanks in advance for your help. I'm new to Python and trying to figure out how to use the threading module to scrape the NY Daily News site for urls. I put the following together and the script is ...

0 answers

Python script adaptation - capturing keyboard input or input submit?

I'm currently using a Raspberry Pi to open my electronic roller shutter at my business premises but am looking to further develop this by using RFID for my customers to open the door whenever they ...

2 answers

Python pandas “filter” a time series for trading days only

I have a two datasets that look like this: What I'd like to do is filter out non-trading days on the "data" dataframe. I assume it would be comparing the data.index.date of each row to the ...

1 answer

using lists for storing data inside loop and conversion to np.array

quite often i do something like: data = [] for i in range(number_of_components): d = some calculation (output may change size) data.append(d) data = np.asarray(data) It is very convenient ...

1 answers | 10 mins ago by Moritz on Stack Overflow stackoverflow.com
2 answers

how do you search and replace in python

I have a server name that is in unc. I need to remove all text from the firs period to the end of the text. for example, server='web01.dc1.example.com" I need this to be: server="web01" I ...

2 answers | 15 mins ago by user1471980 on Stack Overflow stackoverflow.com
1 answer

django-rest-framework + django-polymorphic ModelSerialization

I was wondering if anyone had a Pythonic solution of combining Django REST framework with django-polymorphic. Given: class GalleryItem(PolymorphicModel): gallery_item_field = models.CharField() ...

0 answers

Making a patchwork shape

Is it possible for anybody to point me in the right direction on how to create the image in this question? I have the following code already: from graphics import * def penultimatePatch(): ...

0 answers

Handling Unicode string pulled from SOQL In Python

The purpose of the code is to use SOQL to query the SalesForce API, then to format the data and do some stuff before putting putting it into an oracle database. My code successfully handles the first ...

3 answers

command 'gcc' failed with exit status 1

I tried all answers but I can't solve the problem of installing Biopython package I installed Mingw , but when I try to install the package : python setup.py install I get the following error: ...

3 answers | 21 mins ago by user3216969 on Stack Overflow stackoverflow.com
3 answers

Python - write() versus writelines() and concatenated strings

So I'm learning Python. I am going through the lessons and ran into a problem where I had to condense a great many target.write() into a single write(), while having a "\n" between each user input ...

3 answers | 22 mins ago by AbeLinkon on Stack Overflow stackoverflow.com
6 answers

Python code stucks in Iterating although it found the solution

I'm trying to write a python code to find the prime factors of any given number def pf(n): for i in range(2,n): if n%i==0: #find the factors for j in range(2,i): #check if ...

6 answers | 22 mins ago by Dear_user on Stack Overflow stackoverflow.com
4 answers

Pythonic way to parse preflib Orders with Ties files

I'm working with data from preflib.org, especially with the "Orders with Ties" format. The format looks (somewhat) like this: 1,2,{3,4,5},6 2,{3,6,4},1,5 {2,3},{4,6},{1,5} ... I need to parse every ...

4 answers | 23 mins ago by Megge on Stack Overflow stackoverflow.com
3 answers

Assert that a method was called with one argument out of several

I'm mocking out a call to requests.post using the Mock library: requests.post = Mock() The the call involves multiple arguments: the URL, a payload, some auth stuff, etc. I want to assert that ...

3 answers | 24 mins ago by user1427661 on Stack Overflow stackoverflow.com
0 answers

How to decode file ? python

I have file with name pokemon.txt this file contain one row :<h> 48-481842 :פקס </h> I opened the file and used reges : file = open('pokemon.txt') web_text = file.read() phone_types = ...

1 answer

Print succeeds but logging module throws exception

I'm trying to log the contents of a file, but I get some funny behavior from the logging module (and not only that one). Here is the file contents: "Testing …" Testing å¨'æøöä "Testing å¨'æøöä" ...

1 answer

Creating jpg/png from .ppt/pptx file in django

I have a pptx file on dropbox "https://www.dropbox.com/s/f5167jrxutvj37u/ASD.pptx?dl=0". I want to convert this file to slide images (jpg/png..) in my django template or django def function. I will ...

1 answers | 27 mins ago by Noman Uddin on Stack Overflow stackoverflow.com
0 answers

Python embedded in C++ crash at PyDict_GetItemString call

So I have inherited a C++/Python project. I am totally new to embedding Python calls within C++. double SPython::GetDoubleResult(std::string dictionaryKey) { cout << "Dictionary Key: " ...

3 answers

Naive Bayes: Imbalanced Test Dataset

I am using scikit-learn Multinomial Naive Bayes classifier for binary text classification (classifier tells me whether the document belongs to the category X or not). I use a balanced dataset to train ...

15 30 50 per page
1 2 3