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
2 views
Subclassing matplotlib NavigationToolbar throws error with Pan / Zoom
I'm developing a GUI based filter design and analysis tool (https://github.com/chipmuenk/pyFDA), subclassing matplotlib NavigationToolbar to implement some changes (added / deleted functions and ...
-2
votes
0answers
8 views
When to use nodejs, php, rails or Django?
I am about to start developing a relatively simple bidding web app with a heavy usage of server side. I have experience with Django but I got a strange taste as Django makes you do the thing in a ...
0
votes
2answers
15 views
How to break a list comprised of several lists into just one list?
I am coding in Python.
I am able to write code that returns a list of dates, which I want. Now, for every date, I would like to find the cell value for that date. In order to do that I wrote a for ...
-1
votes
0answers
22 views
Learn Python the Hard Way Exercise 13: name 'agrv' is not defined? [on hold]
Below is my code:
from sys import argv
script, first, second, third = agrv
print "The script is called: ", script
print "Your first variable is: ", first
print "Your second variable is: ", second
...
0
votes
0answers
5 views
PyQt and py2exe: no sound from QSound after compiling to .exe
I have problem with playing .wav sound with QSound.play() after compiling to exe (I'm using Python 3.4.3, PyQt 5.4.1 and py2exe 0.9.2.0).
setup.py code:
from distutils.core import setup
import ...
0
votes
3answers
22 views
Unbound method in Python [duplicate]
In this link while explaining classes, for the following sample class
class MyClass:
"""A simple example class"""
i = 12345
def f(self):
return 'hello world'
it is mentioned ...
0
votes
0answers
7 views
Alternatives of fused type in cython
I am working on rewriting a python module originally written in C using python-C api to Cython.The module also uses NumPy. A major challenge of the project is to maintain the current speed of module ...
-3
votes
1answer
17 views
making a text file in python
I need to write a piece of code which will crate a text file (which the user can create the name), and write it.
python needs to be able to open the file as the code that I already have saves a file ...
0
votes
0answers
11 views
complex matrix in sympy using python
I was using Sympy in Python to conduct some Matrix operations. I have found that Matrix in Sympy cannot process complex automatically. For an easy example
Matrix([[-3007.52907429211/(2898092.62249243 ...
0
votes
3answers
12 views
in Django parameter in reverse never gets interpreted
In Django 1.6, I have a view with a link that is a reverse with a parameter:
edit_link = """<a href="%s"><img src="icon.gif"></a>""" % reverse('bio_filter', ...
0
votes
0answers
5 views
Sync files on upload with Fabric, possible?
I'm using fabric to deploy files to my server. This works by it creating a zip from git and unpacking it on the server. However, I noticed the all it does is overwrite and/or add any new files. If ...
0
votes
0answers
19 views
How to connect two variables by an overlapping name in excel or linux
I first tried to solve it myself with excel and later in Linux, but I cannot seem to solve it. So hope someone can help me with solving this! And not really good in explaining things, so if anything ...
-1
votes
0answers
17 views
How to plot the piecewise continuous points in matplotlib
My dataset is as follows:
G R Y
1 1 0
1 2 1
1 3 2
1 4 4
1 5 2
2 1 1
2 2 2
2 3 3
2 4 2
3 1 0
3 2 1
3 3 2
3 4 2
3 5 3
I want to know how to write the correct matplotlib code to plot the points as ...
0
votes
1answer
15 views
How to synchronize list changes over network in Python
I am developing a little group management system where there are two different types of servers. The "client server" which can join and leave groups on the "management server".
There are multiple ...
0
votes
1answer
10 views
django redirect with full url and primary key in template
Lets say in my form I want to redirect it with form action method with full url which contains primary key too how can I do that ?
<a href="some_url/{}".format(detail.id)>
Here detail is ...
0
votes
1answer
5 views
Django: Automatic assignment of primary key in MySql failing
I am following the Effective Django tutorial with the change of using MySql instead of sqlite3.
Following the official recommendation of Django and given that I am working with Python3.4 I am using ...
0
votes
2answers
6 views
Is it possible to patch a class instance with an existing Singleton instance?
I have a class representing our DB layer which is being instantiated internally in some classes (I cannot pass it as an outside parameter)
For example:
class MyClass(object):
def __init__(self):
...
-10
votes
0answers
33 views
Java to Python?
I am converting a java project into python but dont really know much about pyhton
This is what i am doing in java:
document dom;
DocumentBuilderFactory dbf = ...
0
votes
4answers
17 views
How do I reverse the order of PriorityQueue in python?
I have created a simple priority queue in python that orders items by their value:
import Queue
q = Queue.PriorityQueue()
for it in items:
q.put((it.value, it))
but when i print the queue ...
0
votes
3answers
16 views
It says “TypeError: Oppnadjur() takes exactly 1 argument (0 given)” why?
so this is my function, and it doesn't work.. why?
def Oppnadjur(djurfil):
djurfil = open("djur.txt", "r")
Djur = djurfil.readlines()
Djur.sort()
djurfil.close()
Djurlista=[]
...
1
vote
1answer
17 views
Access base class super in mixin
I've got a class structure that looks like this:
class Question(object):
def answer(self):
return "Base Answer"
class ExclaimMixin(object):
def answer(self):
return ...
0
votes
0answers
4 views
Share python package between appengine modules
I have 3 appengine modules lets say modA (default module-contains app.yaml), modB and modC, which share datastore entities and some utility functions and external libs in an 'common' directory as ...
0
votes
1answer
8 views
Updating a variable that has been casted with theano.tensor.cast()
I am trying to update a theano variable in a function, simplified like this:
copy_func = theano.function(
inputs=[idx],
updates=[
(a_variable, T.set_subtensor(a_variable[some_ptr], ...
-3
votes
0answers
20 views
Sorting Program in Python
Im doing a controlled assessment and need to do a sorting script. When I run the program all I get is errors
Here Is My Code
import csv
import operator
proceed = True
while proceed:
...
-1
votes
0answers
18 views
Dos Attack Server python java
I dont know what is going on on my server. RamNode just adviced me that my VPS appears to e sending out DoS attacks.
I restarted the server and did htop and get this:
gyazo
0
votes
1answer
9 views
Dynamically limit choices for Foreignkey in Django models based on another foreign key in the same model
I have these models:
class UserProfile(models.Model):
name = models.CharField(max_length=100)
class Dialog(models.Model):
belong_to = models.ManyToManyField(UserProfile)
class ...
-3
votes
2answers
31 views
Change all specific letters in a list in python [on hold]
I want to create a program that takes a series of strings as argument, and then exhanges every specific letter in those strings with another letter.
For example:
def ...
0
votes
1answer
31 views
Add random integer to every word in a file
I am creating a script that adds a random integer to every word in a file. All words are integer. So far my script add random integer if input is only one column.
import subprocess
import fileinput
...
0
votes
0answers
6 views
data.replace works in canopy, but not in Geany IDE - TypeError: expected bytes
the script works on the canopy IDE, but not on Geany IDE, which is the one of importance in my case....
the place in the script where it gets stuck (TypeError: expected bytes ...) is at ...
0
votes
0answers
4 views
SQLWorkbench create sql script for only one schema from command line
I've found that : https://github.com/tomoemon/mwb2sql/blob/master/mwb2sql.sh
but is there a way (using the python API I guess) to create a forward engineer sql script for only one schema (and be able ...
0
votes
0answers
3 views
Thread slows down when running cefpython MessageLoop()
I made a simple offscreen renderer with cefpython.
I use cefpython.MessageLoop(), and I have a separate thread to do something every seconds:
[... cefpython initialization ...]
startTime = ...
0
votes
0answers
5 views
Disutils Self Extracting Python Package [duplicate]
Hi Ive been searching around on the interwebs for a while now but cant seem to find anything that covers what Id like using disutils.
Lets say I have a python package dependant on various ...
0
votes
0answers
6 views
Twitter API “Global name twitter is not defined”
Here is my code to extract a users last tweet and color code it. I receive the error"Global name twitter is not defined" not sure whats wrong but am able to access the twitter api and twitter data in ...
-2
votes
1answer
15 views
Unclosed tag 'block'. Looking for one of: endblock
<!--this is my base.html file -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jumbotron Template for Bootstrap</title>
</head>
<body>
{% block ...
0
votes
0answers
16 views
Python xlrd parse Excel xlsx to csv with date conversion
I am trying to parse an Excel.xlsx file to a csv file. Here is the Excel file:
Date Person 1 Person 2
02/03/2015 Bob James A
03/03/2015 Billy Nic
...
0
votes
1answer
10 views
Beautiful Soup default decode charset?
I have a huge set of web pages with different encodings, and I try to parse it using Beautiful Soup.
As I have noticed, BS detects encoding using meta-charset or xml-encoding tags. But there are ...
2
votes
3answers
39 views
grouping elements in the list based in sequential order
I am new to python. Got a complex task to work on.
I have a text file containing a sections separated by comments and commands are in between them. There are multiple sections in the files. I want to ...
0
votes
0answers
7 views
What is the right way to save\load models in Spark\PySpark
I'm working with Spark 1.3.0 using PySpark and MLlib and I need to save and load my models. I use code like this (taken from the official documentation )
from pyspark.mllib.recommendation import ALS, ...
0
votes
1answer
10 views
Retrieve the first href from a div tag
I need to retrieve is the href containing /questions/20702626/javac1-8-class-not-found. But the output I get for the code below is //stackoverflow.com:
from bs4 import BeautifulSoup
import urllib2
...
0
votes
1answer
28 views
Python - Reading text file into dict
I have to read a text file in python into a dictionary, I have tried several options but I can't get it to work.
The format of the text file is the following:
Shop: someshop
Schedule: from 8:00 ...
0
votes
0answers
9 views
create sparse array from diagonal parts
How to construct sparse matrix from diagonal vectors like this:
Lets say my matrix is square with dimension N=6 and i have the following vector
vec = np.array([[1], [1,2]])
and I want to put ...
-6
votes
0answers
27 views
Java vs Python - which one is best for making UNIX system calls? [on hold]
I have a requirement where I need to programmatically make UNIX system calls and apply some logic over the fetched result.
I am a Java enthusiast and I am aware of ways to make system call in Java. ...
1
vote
3answers
24 views
How to use a % after %s in python? [duplicate]
My problem boils down to:
# examplecode
# i want to achieve the string "1.1%"
s = '%s%' % '1.1'
# but this throws me a
ValueError: incomplete format
ofc i could just use format()
s = ...
-2
votes
0answers
18 views
How can I convert a value of a variable to StringVar or IntVar() to .get() it?
I want to get the value in a variable to place it to a text file. But I don't know what method should I do. I tried to convert it using the statement self.score = StringVar() or self.score = ...
-4
votes
1answer
21 views
I have a file with letters and numbers and I want to segregate out the numbers
I have a file with letters and numbers and I want to segregate out the numbers
I tried out the following code, but it fails:
n_file = open("text.txt","br+")
num = ""
while(1):
cch = ...
0
votes
0answers
13 views
How can I have straight contourlines in matplotlib?
I am plotting values with imshow, and I want to have one contourline at a certain value. However, pyplot.contour() uses some kind of interpolation which causes the contourlines to be diagonal around ...
0
votes
1answer
12 views
scipy curve fit failing to fit Lorentzian
I am attempting to use the curve_fit function in scipy to fit a series of Lorentzian curves to a series of peaks.
Currently the code relevant to my problem is:
def ...
0
votes
0answers
14 views
Absurd data when importing from Excel to pandas [duplicate]
I am importing data from a simple Excel file created with LibreOffice Calc to pandas using the xlrd module. One of the cells contains 0.14, but pandas reads it as 0.14000000000001. Another has 0.584, ...
0
votes
1answer
8 views
Using sum() and unnest() with sqlalchemy
I'm trying to figure out proper syntax for using sum and unnest, but I have yet to figure out the proper syntax as currently generated SQL is invalid for PostgreSQL:
sqlalchemy.exc.ProgrammingError: ...
0
votes
0answers
25 views
Python create new object instance and destroy previous
is it possible to instantiate a new object of the same class and destroy the old one? This is because im having a button called "New Game" which will basically destroy this current GUI and call a new ...