0
votes
0answers
12 views

Remove threads usage from script

The next script I'm using depends heavily on threads. What's the easiest way for me to eliminate the treads call and just use the main thread? As a new python developer I tried editing def ...
0
votes
0answers
48 views

simply code to reduce cpu usage

I am trying to run a python script that matches names by year from one input file to a lot of text in another file. I have 100+ name year combinations which I match to the text line by line to see how ...
0
votes
1answer
26 views

Run unittest from Python program via command line option

Here is my set up - project/ __init__.py prog.py test/ __init__.py test_prog.py I would like to be able to run my unit tests by calling a command line option in ...
2
votes
2answers
31 views

What is the best way to read the ith column of a csv file with Python?

I am used to R which offers quick functions to read csv files column by column, can anyone propose a quick and efficient way to read big (data) csv files in python? the ith column of a csv file for ...
0
votes
2answers
29 views

Python 2.7: How to extend a class from an imported base class

New to python, apologies if this is nub stuff: Writing a small module (maybe a package, eventually?). It's gotten too big for single file, so I'm moving my larger classes to individual files. All of ...
0
votes
0answers
19 views

getting user input from mouse click

I was wondering if it's possible to get user input from whatever the user clicks on (e.g a link) and storing it as a string value? For example, I have a link "hello" and when the user clicks on that ...
1
vote
2answers
15 views

Select range of rows from record ndarray

I obtained a NumPy record ndarray from a CSV file using data = matplotlib.mlab.csv2rec('./data.csv', delimiter=b',') The data set is structured as: date,a0,a1,a2,a3, b0, b1, b2, b3,[...], b9 ...
0
votes
2answers
20 views

Why does python urllib2 urlopen return something different from the browser on API call

I need to routinely access and parse XML data from a website of the form: https://api.website.com/stuff/getCurrentData?security_key=blah I cannot post the actual connections because of the secure ...
0
votes
1answer
40 views

HttpResponse object has no attribute get_absolute_url

so i am trying to write my own registration backend because i have to and i am running into some troubles. I get a HttpResponse object has no attribute get_absolute_url and have no idea how to ...
2
votes
2answers
39 views

dict does not reference elements? Python2.7 changed behavior

Given the example: >>> import gc >>> d = { 1 : object() } >>> gc.get_referrers(d[1]) [] # Python 2.7 [{1: <object object at 0x003A0468>}] # Python 2.5 Why is d not ...
-3
votes
0answers
12 views

Python with xmlrpc

I am new to python working on a project. i tried to connect xmlrpc with python using following commands {$ python import xmlrpclib which worked fine further when we ...
-4
votes
0answers
25 views

To receive data from microcontroller using serial communications port. [closed]

I am quite new to python and pyserial. I am trying to do serial communication between micro controller and python. I installed python 2.7.4 and pyserial- 2.5 win32 in my pc. Now what i want to do is, ...
0
votes
0answers
16 views

python multiprocessing.Queue memory consumption & release

I am using a multiprocessing.Queue in a python application. It bridges two processes which have different cpu intensive jobs. At a peak when the consuming process is slow the queue will grow to around ...
-1
votes
1answer
91 views

is it possible to compare string to a variable?

Is this piece of code legal? def ask_to_leave(): if answer == 'y': return False elif answer == 'n': return True I am getting this error: Traceback (most recent call last): ...
0
votes
0answers
15 views

scikit learn: how to go about audio classification? Python 2.7 [closed]

I'm trying to take a few seconds of audio and determine if someone is talking, and if so who. How best to extract features from the audio samples? What classifier to use for audio? How best to ...
0
votes
2answers
35 views

restarting to main function

I am making a macronutrient calculator. This this calculator if the user makes an error calculator simply restarts and goes back to the main(). However, I believe my use of main() in my code causes ...
1
vote
0answers
20 views

Python Multiprocessing Overflow Error

I am testing the Python multiprocessing module to read from different buffer offsets from the same file. The offsets are known a priori and are indexed as 'rows'. The code looks like this: def ...
0
votes
4answers
66 views

Is it possible to randomly *remove* a percentage/number of items from a list & then *append* them to another list?

I am new to python and programming, so apologies in advance. I know of remove(), append(), len(), and rand.rang (or whatever it is), and I believe I would need those tools, but it's not clear to me ...
0
votes
2answers
31 views

Concatenate List Object Name with a Number and Retain the List Python

I'm using python 2.7 I'm trying to figure out a way to change the names of my lists automatically. Let me explain i have multiple lists list1 = [1, 2, 3, 4, 5] list2 = [4, 5, 9, 3] list3 = [8, 4, ...
0
votes
2answers
41 views

Printing error in Python?

I'm new to Python, I've only done programming in Java before recently. I am writing a basic program in Python to print out the 1000th prime number and while I did get it to work, for some reason it's ...
0
votes
1answer
41 views

ValueError: need more than 1 value to unpack python

def main(): sent_file = open(sys.argv[1]) tweet_file=open(sys.argv[2]) scores={} for line in sent_file: term, score=line.split("/t") scores[term]=int(score) the ...
0
votes
2answers
69 views

Can't find the Syntax Error [closed]

I'm writing a simple text based RPG game and I'm trying to get the inventory system to work. I've copied verbatim the working code starting from, but I get a Syntax Error. I'm not sure what I'm ...
-4
votes
3answers
60 views

Learn Python the Hard way ex25 - syntax error [closed]

Ive been going over this for a while and cant seem to find whats wrong with it as im getting a syntax error on line 13. I would love if someone could nudge me in the correct direction here because im ...
-2
votes
3answers
55 views

Efficient way to replace a single element in the list with None

I have a list which contains unique strings. I want to remove a given string (if found in the list) from this list but do not want to change the indicies of all other elements in the list. So I ...
0
votes
1answer
47 views

How do I compute the derivative of an array in python

How do I compute the derivative of an array, y (say), with respect to another array, x (say) - both arrays from a certain experiment? eg, y = [1,2,3,4,4,5,6] and x = [.1,.2,.5,.6,.7,.8,.9]; I want to ...
0
votes
1answer
30 views

Flask: send_from_directory and also refresh the page

I am using send_from_directory in flask which will allow a user to download a certain file. What I want to achieve is that the page refreshes after the file is downloaded, but I'm unsure how I can ...
-1
votes
1answer
12 views

What is the encoding of ciphers in PyCrypto? Need to send to a JS client to decrypt

Using PyCrypto RSA import base64 from Crypto.PublicKey import RSA key = RSA.importKey(open('./keyBR.pub', 'r').read()) privkey = RSA.importKey(open('./privkeyBR.pem', 'r').read()) >>> ...
2
votes
2answers
42 views

TypeError for __init__()

I'm trying to create a nutrition calculator and I'm having a bit of issues regarding init(). def main(): print "Welcome to the MACRONUTRIENT CALCULATOR" User_nutrition = ...
0
votes
0answers
11 views

How to install Orange 2.7 in mac for python scripting

I have python 2.7 pre-installed on my mac. I have downloaded the orange snapshot from http://orange.biolab.si/download/. However on opening the python shell in IDLE and typing "import Orange" it gives ...
0
votes
0answers
28 views

How to use SPDY from Python2.7?

I am trying to use SPDY from Python 2.7. I found the Python-spdylay library as a wrapper around the C implementation. I realize that some parts of the library are Python 3 only. I would like to ...
0
votes
2answers
67 views

Python String Split ^\ is not working

Opening my input file in vi editor is like ACT211111011100000000000000000000000606018^\10421040036991^\M/S DOHAR TRADERS^\BD^\167^\050^\000000579300^\000000579300^\ ...
0
votes
1answer
13 views

widget=“float” for char field

I have problem in alignment of tree view column so I change my field from "float" to "char" type and giving widget="float" to accept only number or float or integer values. I declared in .py file ...
1
vote
1answer
44 views

TypeError: “quotechar” must be an 1-character string

I am trying to read data from a csv file. I set quotechar to csv.QUOTE_NONE. The four lines of Python I wrote for this purpose are just as follows - import csv with ...
-1
votes
2answers
21 views

How to add data using python from one sheet to an existing sheet in another workbook without overwriting other sheet's data?

I have an two excel files 'file1' and 'file2'. file1 has data filled in 3 sheets. I want to copy data from file2 and append it into sheet3 in file1 and save the same file. Can anyone help me do this ...
0
votes
0answers
62 views

Can anyone please help me in understanding the following python code

I found the following code for Merge Sort and I can't undesrtand how it works def mergeSort(alist): print("Splitting ",alist) if len(alist)>1: mid = len(alist)//2 lefthalf ...
0
votes
0answers
10 views

RSA - PyCrypto and Javascript RSA libraries (PidCrypt) ecoding problems

I need to send a string encoded in RSA between a Chrome extension and a Python webserver, the reply will also need to contain an encrypted string. The communication is indirect, so SSL won't do, as ...
0
votes
0answers
24 views

failed: ImportError: cannot import name splitgophertype

I get this error when I import the python modules to Robot Framework. But when I run the .py modules independently outside it works fine. Can someone tell me why do I get splitgophertype error [ ...
0
votes
0answers
36 views

Python, default value taking other assigned value

I'm trying to assign a default value if none is set. But this is working too well. Indeed when I set a real value like: print run(sys.argv[1], sys.argv[2], AS="ppm") or print run(sys.argv[1], ...
0
votes
0answers
50 views

Twisted drops connection when new data received

I've a service made with twisted. Everything had worked fine until I've moved to a new server. Now my service drops most of connections when new data received. Old server was 32 bit Windows XP and the ...
0
votes
2answers
56 views

How to shorten long “and” statements? [duplicate]

I have a looong statement of "and"'s, for example: if this == that and this == that and this == that: do this How to correctly break such statements into separate lines, to comply with PEP-8?
-1
votes
0answers
11 views

django-profiler (profiling logger)

Using context manager approach, output is logged to a profiling logger. from profiling import Profiler with Profiler('Complex Computation'): # code with some complex computations I wanted to ...
0
votes
1answer
47 views

How to accept user input without waiting in Python

I'm creating an IRC bot and I want to be able to constantly receive from my buffer, but at the same time if I type a command into the console I want it to be readily accepted. So far I have a infinite ...
2
votes
1answer
44 views

What is a good alternative to use assignment in map function in python?

It is illegal to use assignment in map function, such as map(lambda in: test[in]+=value[in], somelist) So what is a good alternative for it. You could use for loop to do this, but it seems to me ...
0
votes
2answers
45 views

How do I capture words wrapped in parentheses with a regex in Python?

I have this string named jumpball u'\n (12:00) Jump Ball Hibbert vs Bosh (Chalmers gains possession)\n ' I want to extract Hibbert, Bosh and Chalmers I can find the first ...
0
votes
0answers
16 views

Multiply tuple elements if the first element in a tuple matches else ignore

I have a list of tuples like below [(0, 33), (3, 26), (4, 95), (0, 28), (1, 12), (2, 3), (4, 69)] I want to multiply the second elements of the tuple IF the first element matches (once or more); ...
0
votes
1answer
16 views

Python 2.7- statsmodels - result.conf_int()

This post is an addition to the post found here: Python 2.7 - statsmodels - formatting and writing summary output I got everything formatted how I need, except the confidence interval is giving me ...
0
votes
1answer
18 views

Trouble installing Turbulenz

I was trying out the HTML5 Game Engine Turbulenz, which requires Python to be installed on the machine. I downloaded and installed Python, and then I downloaded the installer for Turbulenz. In the ...
0
votes
0answers
37 views

Python facebook desktop application

I'm trying to make a desktop application in python 2.7 (I'm using python-facebook-sdk) which would allow user to log into his account and then do some basic actions (like displaying his wall messages, ...
0
votes
3answers
45 views

merge dictionaries in python with common key/value

I am looking to merge dictionaries in Python with dictionaries that have a common value then key. Currently, I have a nasty loop inside of a loop inside of a loop. There has to be a better way... ...
0
votes
2answers
34 views

RSA communication between Javascript and Python

I am working on a prototype, so it needs to use RSA between a Chrome Extension and a Python Server. So far I was planning on using https://www.pidder.com/pidcrypt/?page=demo_rsa-encryption and ...

1 2 3 4 5 97
15 30 50 per page