Tagged Questions
Python is a dynamic and strongly typed programming language that is designed to emphasize usability. Two similar but incompatible versions of Python are in widespread use (2 and 3). Please consider mentioning the version and implementation that you are using when asking a question about Python.
0
votes
0answers
6 views
Django: removed object causes IndexError
I am a bit confused and I need some help.
I am displaying my objects using ModelFormset, then I am dynamically removing them using Ajax and then saving all of the objects again also using Ajax call. ...
0
votes
0answers
2 views
wxPython Animation - Tween Animation
I was wondering if it was possible to have tween animation in wxPython. I have tried looking at all the documentation but cannot seem to spot an reference to it. An example of what I am after would be ...
0
votes
0answers
23 views
IndexError in python
I am working in python based in a java code.
I have this in Java:
public static byte[] datosOEM = new byte[900000];
public static byte x1=0,x2=0,x3=0,x4=0,x5=0,x6=0;
I wrote this in python ...
0
votes
0answers
5 views
Custom Matplotlib ColorBar for Scatterplot
I current have a few scatter plots each in their own sub plot. The way the data is formatted is:
ID, X, Y, Colors, Area
0, x1, y1, r, 1
1, x2, y2, g, 1
2, x3, y3, r, 3
3, x4, y4, b, 4
....
n, xn, yn, ...
0
votes
1answer
6 views
Using Pycurl in Pycharm
I'm trying to run a script that begins:
from pycurl import *
However, this throws the error:
Traceback (most recent call last):
File "/Users/adamg/PycharmProjects/untitled/UrlToText.py", line 1, ...
0
votes
0answers
7 views
getting html form data into django views
I am doing web based python project in Django. I've webpage which contains a textbox and a submit button. whenever a user enters some data in textbox and clicks on submit button then that data is ...
1
vote
1answer
5 views
Django Admin - how to forbid to create already existing object
I have a Model:
class Category(models.Model):
CATS = (
('CT', 'Cool Things'),
('II', 'Internet & IT'),
('BT', 'Beautiful Things'),
)
cat = models.CharField(max_length=2, ...
0
votes
0answers
6 views
extracting text from a pdf with pdftotext
I am trying to extract text from a pdf with python and pdftotext.
I have weird characters and I don't know what's wrong.
For example, for this :
It gives me this:
There is a problem for "Belgium".
...
0
votes
0answers
3 views
rpy2 dtw missing argument window.size
I'm using the R DTW package with rpy2. I would like to be able specify a window type and size for running the DTW analysis.
I have run the following code:
import numpy as np
import rpy2.robjects as ...
0
votes
2answers
37 views
Python Object Test
I have the following unittest questions I am trying to pass.
def test_map2(self):
self.home = []
self.home.append(Bed('Bedroom'))
self.home.append(Sofa('Living Room'))
...
0
votes
1answer
16 views
Grouping, sorting lines and removing redundancies
I have an input file having 15 columns,
con13 tr|M0VCZ1| 91.39 267 23 0 131 211 1 267 1 480 239 267 33.4 99.6
con13 tr|M8B287| 97.12 590 17 0 344 211 1 267 0 104 239 590 ...
0
votes
0answers
13 views
a fast way to get human genome sequence by coordinate
I want to get a lot human genome fragments (more than 500 million of them) randomly.
This is a partial work of the whole process. I have .sam result file from bowtie, with 10 million human genome ...
-1
votes
0answers
9 views
apache and python command line arguments
I am trying to setup up psdash with apache. PSDASH requires commandline variables to be passed to it and I was wondering how this was acheved within apache.
Any help would be great
Thanks
0
votes
0answers
9 views
Python - mysql - Google app engine: Runtime error
I just started developing python-google app engine apps on MacOS.
I keep getting a "ImportError: No module named mysql.connector" while trying to access a database during Runtime.
whats surprising ...
0
votes
0answers
15 views
Towers of Hanoi in Python in Maya Autodesk
I'm currently trying to write a script in python in maya that will solve the towers of hanoi problem with n number of discs. The example I have been given is:
The towers of Hanoi in Python
def ...
0
votes
0answers
31 views
Python : reading the output of a function with variable return type
I need to use a function from a package that returns either a single object or a numpy array of objects. I would like to read the output of the function in a numpy array, irrespectively of the type of ...
1
vote
0answers
14 views
SciPy: converting 1/0 sparse matrix to 0/1 sparse matrix
What is the fastest way to convert 1/0 sparse matrix to 0/1 sparse matrix without using todense() method?
Example:
Source matrix looks like:
matrix([[1, 1, 0, 0, 0, 0, 0, 0, 1, 1],
[1, 1, ...
0
votes
0answers
7 views
Install freetype library module in python
need help installing freetype library in python. Already installed GNUWin 32 and freetype-py but still getting "RuntimeError: Freetype library not found" when importing freetype in python...
Úsing ...
1
vote
1answer
10 views
Python mechanize saying existing control does not exist
I am trying to scrape a password protected website in python. My code is as follows:
import mechanize
import cookielib
from BeautifulSoup import BeautifulSoup
br = mechanize.Browser()
cj = ...
1
vote
2answers
15 views
import from views.py does not work from app
I'm working with django and I'm trying to get a simple app functional.
The app is supposed to deliver a simple 'Hello world'-view but my_app/urls.py fails to import methods from my_app/views.py.
my ...
0
votes
1answer
22 views
can python numpy poission generate a float?
I'm trying to generate poission instances with the numpy library:
arrayVal = np.random.poisson(lambda_,k)
but it only generate me a array of type Int.
is there a way in numpy to return a float ...
0
votes
0answers
16 views
Operating on Pandas groups
I am attempting to perform multiple operations on a large dataframe (~3 million rows).
Using a small test-set representative of my data, I've come up with a solution. However the script runs extremely ...
0
votes
0answers
9 views
Pandas: boolean indexing with unequal Series lengths
Given two pandas series objects A and Matches. Matches contains a subset of the indexes of A and has boolean entries. How does one do the equivalent of logical indexing?
If Matches were the same ...
0
votes
0answers
9 views
Class based login form by wrapping authentication form not working
I am trying to rewrite login view by using class based views. I can see no errors but my form doesn't load. I am using ajax to serve the form.
class Login(FormView):
form_class = ...
2
votes
1answer
17 views
Python: open existing Excel file and count rows in sheet
I have an existing Excel file. I want to load that one and get the count of rows in this sheet, to later write in the next row of this sheet and save it again. I get following error messages:
...
0
votes
0answers
13 views
How would I streaming the last 60 seconds of audio in python [on hold]
I am working on an application that will constantly record the last 60 seconds of audio around the computer. At any moment I would press a key and it would save that audio for processing later.
...
1
vote
3answers
40 views
How to access a value in a dictionary of a list and add it (counter)
so basically I have a list of numbers called numList.
Ex. [11,54,22,42,5,16,79,18,39]
I also have a dictionary of lists dictionary.
Ex. {0:[10,20,0],1:[15,20,0],2:[20,30,0], 3:[30,90,0]}.
My goal ...
1
vote
2answers
21 views
subtract from value inside dictionary in a list python
I have a list of dictionaries and would like to subtract 1 from the value of the key "quality" in all dictionaries from the list
list=[{key1:xx, key2:xx, quality:5},{key1:xx, key2:xx, ...
0
votes
0answers
4 views
second level nested inlines not showing in django-nested-inlines
I'm trying to add a nested admin interface using https://github.com/s-block/django-nested-inline but the 2nd level is not showing up in the admin...
I have a foreign key relationship between three ...
0
votes
1answer
18 views
How to find if a specific letter is a part of a word, and how to get its index?
I need to write a function which gets a word and a letter and gives as an output the index of the first appearance of the letter in the word.
running examples :
char_first_index("aabcb","b") #would ...
1
vote
1answer
14 views
Make a Custom Class JSON serializable
I have a custom class, let's call is class ObjectA(), and it have a bunch of functions, property, etc.., and I want to serialize object using the standard json library in python, what do I have to ...
0
votes
0answers
6 views
ImportError: cannot import name GdkX11
I'm a Windows developer and trying start PyGTK development. I want start with GTK+3 and folow this documentation.
My environment:
Windows 7 64bits
Python 3.2 32bits
...
0
votes
0answers
8 views
Installing pip for Python 3.4 - Mac OS X
as you know the Mac comes with Python pre-installed, mine has the 2.7 version. I installed Python 3.4. I installed pip using the command
sudo easy_install
however it gets installed to the 2.7 ...
0
votes
2answers
21 views
Once opened and n-times written or n-times open but one time written per openning?
So the problem is - which case to use? I got list of urls and got some magic function get_text_from_url - and I have to write this into the file with given filename - simply as can be, but which case ...
2
votes
1answer
15 views
How to iterate over all optional arguments and related values?
I am new to Python and I would like to implement a script.py so to handle the following command
python script.py --opt value1 --opt value2 --opt value3 ... --opt valueN
and to print all --opt ...
0
votes
2answers
30 views
why does not work clean ()?
please help to solve the problem . on the page is a form of :
from django import forms
from userprofile.models import UserProfile
from django.contrib.auth.models import User
from django.forms import ...
0
votes
1answer
7 views
logging.StreamHandler.setLevel(logging.DEBUG) <— doesn't work
I don't know why it can't log that message, i think everything is correctly set.
And logging.DEBUG is defined under logging module
import logging
import sys
logger = ...
1
vote
1answer
12 views
How can be used multiple filter in the numpy array?
I am trying to filter some data out from an array
data = data[data['RotSpeed'] <= ROTOR_SPEED ]
data = data[data['HorWindV'] <= WIND_SPEED ]
I am wondering if this can be optimized by ...
1
vote
1answer
14 views
how to specify version of python to run a script?
Hi I'm learning python now using a mac which pre-installed python 2.7.5. But I have also installed the latest 3.4.
I know how to choose which interpreter to use in command line mode, ie python vs ...
0
votes
0answers
12 views
python matplotlib: how to automatically save figures in .fig format?
With python matplotlib module, we can use pylab.savefig() function to save figures.
However it seems that this function can't be used to save figures in .fig format.
The .fig format is matlab figure ...
0
votes
0answers
15 views
Converting character counts to token counts
My problem is the following. I have a string that contains a few English sentences. I also have a separate list of annotations that have been made on that string that are of the form
...
1
vote
0answers
13 views
Django - What is the best way to set up a model with lots of similar fields?
I'm trying to set up a questionnaire for users which would equate to nothing more than a big form with lots of radio choices. So my model is going to need spaces for a bunch of questions. My idea is ...
2
votes
2answers
12 views
Formatting datetime xlabels in matplotlib (pandas df.plot() method)
I can't figure out how to change the format of these x-labels. Ideally, I'd like to call strftime('%Y-%m-%d') on them. I've tried things like set_major_formatter but was unsuccessful.
import pandas ...
0
votes
1answer
8 views
keyError in Flask application using Stripe's checkout
I am making a simple flask application using stripe's checkout.
just like in:
https://stripe.com/docs/checkout/guides/flask
- app.py
but I am getting error:
Traceback (most recent call last):
File ...
0
votes
1answer
22 views
Pass information between requests webapp2
Is it possible to pass information between requests with webapp2?
I have a class that has to set the author variable on HTTP GET. The HTTP POST will check if author exists, and then continue posting. ...
0
votes
0answers
14 views
Converting a Doc to HTML using abiword in Dijango
I have a requirement where I have to convert any doc file to html, and below is the code
data=RWFField.objects.get(id=data_key)
data_dictionary = {}
file_path = str(data.uploadedFile)
tmp = "/tmp"
...
-7
votes
1answer
36 views
PHP or Python for a webservice? [on hold]
I did a REST webservice with Python. As I need to expand it, I'm wondering if Python is really the best choice. My team is working on both PHP and Python. Is one better than the other in terms of ...
-5
votes
0answers
15 views
Should I use JSON api for app and web page? [on hold]
I using Django to build site, but I need to develop a app(Android) too.
Should I using JSON API(such as update UserInfo) in App and Web Page both?
Or, I should just using JSON API in App, HTML is ...
2
votes
5answers
34 views
Query on usage of dictionary in JavaScript
Below code is creating a dictionary(foo) and then adding a method(bar) and property by name ack in that dictionary.
var foo = {};
foo.bar = function(){
this.ack=3;
};
foo.bar();
In python, if ...
0
votes
0answers
10 views
How to read compressed HDF5 file using h5py
I want to read a compressed hdf5 file using h5py file but I am not getting any hint, how to do that. I was trying to read hdf5 file using ordinary way and I was getting error message which is linked ...