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
Override django-taggit tags so that they are always lowercase
I couldnt find a good answer or solution for multiple tags in a model. the only thing I found close was this:
How can I limit django-taggit to accept only lowercase words?
here is my current code:
...
0
votes
0answers
3 views
How to install xmlrpclib in python 3.4?
When I am trying to install xmlrpclib, I am getting following error in python version 3.4
Downloading/unpacking xmlrpclib
Could not find any downloads that satisfy the requirement xmlrpclib
Some ...
0
votes
0answers
5 views
pyqt5 cx_freeze compilation
i try to make exe with cx_freeze, when compiling i get this messages: http://wklej.org/id/1457081/
and when i run my output file i get: http://i.imgur.com/t5E7GS2.png
my setup is simple:
# -*- ...
0
votes
0answers
4 views
How do I change the completion delay in IDLE?
According to the IDLE help, "The AutoCompleteWindow (ACW) will open after a predefined delay (default is two seconds) after a '.' or (in a string) an os.sep is typed."
I would like to change the ...
0
votes
1answer
17 views
Python method not affecting instance of Class
My question is in the del_node method, despite setting self = self.next, this seems to have no affect on the instance of the class thats making the call.
for instance,
if i have a linked list L = 1 ...
0
votes
0answers
8 views
Signal handling in multi-threaded Python
This should be very simple and I'm very surprised that I haven't been able to find this questions answered already on stackoverflow.
I have a daemon like program that needs to respond to the SIGTERM ...
0
votes
0answers
5 views
Efficiently copying slices of large numpy arrays to a smaller array of continuous memory
I have a need for copying slices from a large numpy array to another smaller array as efficiently as possible. Ultimately, the smaller array will be passed as a two dimensional array into a C function ...
-1
votes
0answers
14 views
How do I find the physical path from a url in Pyramid and Python?
I have a website built in Python's Pyramid platform. I would like to convert a URL to a physical file in code.
For example, given the url:
/site/static/css/site.css
I would like to call some code ...
1
vote
0answers
13 views
Python Parameterized Queries with Special Characters and UTF-8 Characters
I'm new to python so I apologize for something I assume is an easy question, but haven't been able to find a good reference on how to do it. I think I might be confused about how to use of unicode ...
0
votes
1answer
7 views
How to send HTML email through Outlook with a different mail-from (win32com.client)
Brief background:
I'm writing a script to send a template for work, but I normally send messages as our team mailer for visibility within my team. Most of it is working as expected, but I am missing ...
0
votes
0answers
25 views
What are functional differences between DEBUG = True and False in Django?
What precisely are the functional differences between toggling the DEBUG setting in a settings.py file of a Django app?
I first assumed DEBUG=True merely turned on Django's logging capability and ...
0
votes
0answers
7 views
Serving static files on S3 with Django DEBUG set to False
I have my Django Heroku app up and running only when DEBUG=True in the settings.py (same problem as here)
As soon as DEBUG=False, it gives me status 500 errors (even after collectstatic is performed) ...
0
votes
5answers
25 views
How to extract a specific symbols from string if they follow after the number
I need to extract a single or multiple symbols @ from a string. I only need those symbols that follow one after another and are not separated with any characters and white spaces.
The symbol or ...
0
votes
0answers
13 views
Pandas index column for a dataframe
Hi all so I'm trying to work with this set of data that has two columns, one is names and the other is the number of births for each name. What I want to do is import a csv file, perform some basic ...
0
votes
0answers
9 views
can't import is_secure_transport
I am using TwitterAPI of python(ubuntu+pycharm).
I install TwitterAPI by "pip install networkx TwitterAPI".
I just import TwitterAPI as follows:
from TwitterAPI import TwitterAPI
When I execute ...
-1
votes
2answers
8 views
Rescale a numpy array
I have a 2D numpy array that represents a monochrome image from a CCD that has been binned 3x3 (that is, each value in the array represents 9 pixels (3x3) on the physical CCD).
I want to rescale it ...
0
votes
1answer
24 views
Using global variables in Python modules
I have these 4 modules
globals.py
globvara = "a"
mod1.py
from globals import *
print globvara
output : a
mod2.py
from mod1 import *
def changegv(newval1):
#global globvara
globvara = ...
0
votes
0answers
18 views
How to Cython optimize this Pandas Python code?
I have issued the "prune" command on my code, in ipython and got this output:
ncalls tottime percall cumtime percall filename:lineno(function)
675306 0.542 0.000 0.756 0.000 ...
0
votes
0answers
5 views
Capturing high multi-collinearity in statsmodels
Say I fit a model in statsmodels
mod = smf.ols('dependent ~ first_category + second_category + other', data=df).fit()
When I do mod.summary() I may see the following:
Warnings:
[1] The condition ...
1
vote
1answer
21 views
Why is FrozenList different from tuple?
from pandas.core.base import FrozenList
Type: type
String form: <class 'pandas.core.base.FrozenList'>
File: /site-packages/pandas/core/base.py
Docstring:
Container that doesn't ...
0
votes
2answers
18 views
Access enclosing “with” statement implicitly
I am working on something like a logging component and I want to use it like this:
with logging.Log(context='A', message='msg1') # with1
do_stuff()
As you can see Log implements a with ...
0
votes
1answer
12 views
Add field for dynamically generated url in Django admin
I have a Django model that has a property called url that when accessed, returns a S3 signed url of a document on s3. Sign URLS have expirations, so I am not saving to the model, it needs to be ...
0
votes
0answers
4 views
Matplotlib continuing line into infinity
I have a graph, made from data in .txt files. Currently, Matplotlib will graph it to the last point in my file. I need it to continue farther that that. I seem to remember something somewhere saying ...
-1
votes
1answer
15 views
Alternative to gevent for python3?
What is a good alternative for gevent that is python3 compatible?
I am finding trouble finding any python3-compatible libraries to use on the python side. Any suggestions?
2
votes
2answers
20 views
Web-crawler for facebook in python
I am tring to work with web-Crawler in python to print the number of facebook recommenders. for example in this article from ...
1
vote
1answer
17 views
How do I express this query in SQL Alchemy
I am trying to query a table in an existing sqlite database. The data must first be subsetted as such, from a user input:
query(Data.num == input)
Then I want to find the max and min of another ...
0
votes
1answer
6 views
Installing Pillow error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
While i try to install Pillow 2.5.3
I am getting an error : command 'x86_64-linux-gnu-gcc' failed with exit status 1
Here is the complete log of what happened
I need this library as a part of ...
-3
votes
1answer
15 views
Making a symbolic function callable — sympy
I'd like to calculate the derivative, then solve for when it is zero.
I am using the sympy module to do this.
r = somefunction(x1,x2)
Using this function, I'd like to be able to call these two ...
1
vote
2answers
29 views
How can I concatenate str and int objects?
If I try to do the following:
things = 5
print("You have " + things + " things.")
I get the following error in Python 3.x:
Traceback (most recent call last):
File "<stdin>", line 1, in ...
1
vote
2answers
17 views
How to extract numbers from string separated with minus sign
I need to be able to extract two numbers from a string. I know those two numbers (if presented in a string) are separated from each other with '-' character.
a='some text'
b='some 0-376 text'
c='some ...
0
votes
1answer
12 views
Python CGI URL Redirect
I am currently writing a CGI python script. Once I have time I will rewrite this in web2py, but simply have no time ATM for this.
I have the whole logic built, except for one thing. I need to be ...
0
votes
1answer
13 views
How to do JSON field validation
I have a Restful web service that gets the content from JSON schema. Now I want to validate the fields of this JSON schema. My web service registers the user, hence I have fields like first_name, ...
0
votes
1answer
23 views
Python “print” coming after while loop even though it's physically before?
I'm messing around with some python (in eclipse using dynamic language toolkit) and even though I have the print command a line before my while loop, I have to enter the values and type "done" before ...
0
votes
1answer
15 views
HTTP 500 Error with Django Ajax
I'm trying to use Django with AJAX calls, and it's giving me HTTP 500 even of MultiValueDictKeyError even though there's nothing wrong?
I sent 3 variables: sendEmail, username, error
I was able to ...
0
votes
1answer
16 views
Unit Testing with Range Function
I will try to be as clear as possible. I've been practicing unit testing for a while now, and I'm now trying to figure out how to test the below code.
def main():
for i in range(100):
...
0
votes
1answer
13 views
Pickling a dict inside a PyQt app
I'm attempting to dump a pickle file in my PyQt app only its seems to be completely ignoring the statement.
import cPickle as pickle
class MyActions(QtGui.QMainWindow):
def __init__(self, ...
1
vote
0answers
13 views
Need a similarity measure for these vectors
I have a Python function that takes in a block of text and returns a special 2D vector/dictionary representation of it, depending on a chosen length n. An example output might look like this:
1: [6, ...
0
votes
2answers
10 views
How to access properties of referenced objects in Jinja2 templates (Google App Engine)
Consider the following data model in Google App Engine
class A(ndb.Model):
name = ndb.StringProperty()
b = ndb.KeyProperty(Kind='B')
class B(ndb.Model):
name = StringProperty()
now ...
0
votes
3answers
44 views
get the path in a file inside {} by python
I have a code and I just want to have /X/Y/Z/C, /X/Y/Z/D, /X/Y/Z/E back(whatever comes after -tree).
It should actually reads the file, ignores everything till it sees WFS and then get the information ...
1
vote
1answer
11 views
Accessing Amazon Web Services SQS Queue in Python
I currently have an Amazon Web Services SQS queue which I use throughout my php project. I am trying to now write a service in Python which adds items to the SQS queue. However I cannot get a ...
0
votes
0answers
2 views
Theano scan missing input error
Numpy multinomial sample generation is not generalized for any given shape(Multinomial sample generation in python) I tried to loop over probabilities and generate samples. I am trying this using ...
0
votes
3answers
33 views
Use Python 2 Dict Comparison in Python 3
I'm trying to port some code from Python 2 to Python 3. It's ugly stuff but I'm trying to get the Python 3 results to be as identical to the Python 2 results as possible. I have code similar to this:
...
0
votes
1answer
25 views
random values from specific function python
let's say I want to pull out random values from a linear distribution function, I'm not sure how I would do that..
say I have a function y = 3x then I want to be able to pull out a random value from ...
1
vote
3answers
28 views
How to check to see if a folder contains files using python 3
I've searched everywhere for this answer but can't find it.
I'm trying to come up with a script that will search for a particular subfolder then check if it contains any files and, if so, write out ...
0
votes
2answers
17 views
Making the while loop del guess from card[list]
import random
card = ['ace of spades', 'two of spades', 'three of spades', 'four of spades',
'five of spades', 'six of spades', 'seven of spades',
'eight of spades', 'nine of spades', ...
3
votes
1answer
16 views
Using rolling_apply with a function that requires 2 arguments in Pandas
I'm trying to use rollapply with a formula that requires 2 arguments. To my knowledge the only way (unless you create the formula from scratch) to calculate kendall tau correlation, with standard tie ...
0
votes
5answers
45 views
python: how can I access subsequent lists in a nested list
I'm working with a nested list. I'm using a for loop to iterate through it. Sometimes a particular item in the list is dependent on a subsequent nested list. I tried iterating and using next, but that ...
1
vote
2answers
29 views
How to use raw_input with argv?
I'm doing ex13 from Learn Python The Hard Way
I'm trying to pass:
python ex13.py raw_input() raw_input() raw_input()
my code is below:
from sys import argv
script, first, second, third = argv
...
0
votes
0answers
4 views
Using a proxy with JavaScript and other plugin requests in Qt
I'm trying to use a proxy with Python and Qt. I found it pretty easy to set up a proxy for the QWebView using QNetworkProxy.setApplicationProxy(), but had a lot of difficulty getting the proxy to work ...
0
votes
1answer
8 views
Change window size each tab tkinter notebook
I am a new tkinter user, and I was starting to make a notebook of some math programs. I wanted to make it so that the size of the notebook window changes based on the tab. So in tab1, there are more ...