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
Tool or script to extract a list of non-built-in modules/packages in a Python project/repo?
Sometimes, I like to check a Python project's install_requires in setup.py to see if there is some Python modules/packages missing.
Given a Python project. Ex, cloned from a repo.
Assume all .py ...
0
votes
0answers
3 views
Python int too large to convert to C long code needs fix
Hey guys I keep getting this error when I run my code
Traceback (most recent call last):
File "Jacobi.py", line 93, in <module>
limit, guess, statement = jacobi(sys.argv[1], sys.argv[2])
...
0
votes
0answers
5 views
Python: combinations for each dictionary in a list
Not sure if this is possible or not. Assuming I have a list of dictionaries like follows:
stocks = [{'name': 'bob', 'avg_returns': '18.345', 'sd_returns': '2.14', 'var_returns': '34.2334'}, ...
0
votes
0answers
10 views
Pyhton - Print elements of two arrays in ascending order using loop
I would like to print values of 2 arrays out in ascending order using loop.
Which ever having the smaller value will loop out their value. Hence, they will take turn to iterate.
*The values in each ...
0
votes
0answers
9 views
how to replace the characters of the list in python
I want to write a code in python that will replace every every small letter character with "a" , every capital letter with "A" and every digit with 0. I write code but it caused an error of x not in ...
0
votes
0answers
4 views
Edit XML file text based on path
I have an XML file (e.g. jerry.xml) which contains some data as given below.
<data>
<country name="Peru">
<rank updated="yes">2</rank>
...
0
votes
0answers
2 views
matplotlib show many images in single pdf page
The following python script is given an image as input and shows it 8 times in a single pdf page:
pdf = PdfPages( './test.pdf' )
gs = gridspec.GridSpec(2, 4)
ax1 = plt.subplot(gs[0])
ax1.imshow( ...
0
votes
0answers
5 views
Newrelic Python Agent: Error logging handled exceptions
I've got a Python-based REST API. When an exception is hit during the execution of an API request, I generally try to catch the exception, log it, and return a generic error message along with an ...
0
votes
1answer
8 views
ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI
The question is why I see the error message in the title when trying to import enchant. I am using Win64.
0
votes
0answers
1 view
sklearn.linear_model.RandomizedLogisticRegression : Handle Categorical Value
I want to use RandomizedLogisticRegression for selecting variable for my data set. But the problem is that, One of the feature in my data set is Gender. So it's values are 'F' or 'M' instead of ...
0
votes
1answer
11 views
cookie request with python
I created a personal plugins for xbmc (kodi) and I have a problem with my request to get smill files.
Example smil files:
...
0
votes
1answer
13 views
How to fix compiler error: cannot convert to a pointer type with Cython + numpy?
I'm trying to wrap a C function for use in Python using Cython and numpy.
When I compile I get the following error:
_fastlp.c: In function ‘__pyx_pf_6fastlp_fastlp_func’:
_fastlp.c:1351:3: error: ...
0
votes
0answers
7 views
How to convert dynamo items from scan to dict/json?
I am using boto to retrieve dynamo Items from a scan.
for item in scan_results:
print item
I can access each property with:
for item in scan_results:
print item['propA']
for item in ...
0
votes
1answer
44 views
Is this a constructor or a method
Is __init__ in python a constructor or a method?
Somewhere it says constructor and somewhere it says method, which is quite confusing.
1
vote
0answers
9 views
Read and Write special characters in XML with minidom
I'm trying to write and read back a set of strings in elements called objects which has two attributes name (simple string ) and body the body is a string with special characters "\n" and "\" I'm ...
0
votes
0answers
6 views
How to have a fixture loaded for Django tests in the test runner?
I have a large set of Django test cases, all of which subclass either TestCase or TransactionTestCase. I need to add a fixture to all test cases (to handle a new way of handling settings in the ...
0
votes
3answers
25 views
Fuzzy-match List of People
I am trying to see if a movie is the same between two pages, and to do so I would like to compare the Actors as one of the criteria. However, actors are often listed differently on different pages. ...
0
votes
0answers
16 views
why would load_module be called if the module is already in sys.modules?
PEP302 says that load_module must return entry in sys.modules if one already exists. That seems like an unnecessary burden, because the caller (i.e. Python's import system) could simply look in ...
0
votes
1answer
14 views
How do I post to Django /accounts/login/ from mobile native application?
I use Django 1.6 and Python2.7 and develop web application.
I post there parameters from mobile native application.
csrfmiddlewaretoken
username
password
but, 403 FORBIDDEN was happened.
Could you ...
0
votes
0answers
7 views
Multiple outputs from wtforms flask
How do I get multiple outputs printed on a page from one single wtform?
So I have a form created on forms.py
class PostForm(Form):
content = StringField("What's up?", validators=[DataRequired()])
...
1
vote
4answers
51 views
How to make array into array list in python
from this array
s = np.array([[35788, 41715, ... 34964],
[5047, 23529, ... 5165],
[12104, 33899, ... 11914],
[3646, 21031, ... 3814],
[8704, 7906, ... ...
1
vote
1answer
13 views
Pandas extract columns from dataframe which are not present in another dataframe
I have foll 2 dataframes:
df_A
A B C D
12 23 34 45
22 32 54 87
and,
df_B
B C
23 34
32 54
How do I select the columns in df_A which are not present in df_B, ...
1
vote
1answer
15 views
How to simulate HTML5 Drag and Drop in Selenium Webdriver in Python
I am using Python 2.7 and Selenium 2.44.
I want to automate drag and drop action in Selenium WD but according to other related posts Actions in HTML5 are not supported by Selenium yet. Is there any ...
0
votes
2answers
20 views
Improving the execution time of matrix calculations in Python
I work with a large amount of data and the execution time of this piece of code is very very important. The results in each iteration are interdependent, so it's hard to make it in parallel. It would ...
2
votes
1answer
57 views
Is there a way to pass arguments using the dot operator in python?
I'd like to the make a clean, "smart" method that performs specific operations without passing in arguments. I have some code that works in principle as follows:
class Foo():
def __init__(self, ...
0
votes
0answers
10 views
How can I get continuous motion in pygame?
def function():
import pygame
import time
from pygame.locals import *
pygame.init()
Width = 272
Height = 552
white = 255,255,255
blue = 0,255,255
red = 255,0,0
...
0
votes
0answers
18 views
How do I send data to flask server via AJAX?
I am trying to mark the tasks that are checked as checked in the database. How do I use jquery to send the data to the python server and then have it mark it as checked?
//python
...
0
votes
1answer
17 views
Importing JSON into mysql using python
Im trying to import this into mysql,
I have the json output:
{u'age': u'27',
u'foulsCommitted': u'36',
u'foulsSuffered': u'19',
u'goalAssists': u'0',
u'no': u'18',
u'pla': u'Jaume Costa',
...
0
votes
0answers
15 views
How to set the id attribute of a WebElement?
According to the selenium API doc, there is a function getAttribute but there is no setAttribute
Ideally I would like to be able to do the following:
element.set_attribute('id', 'abcd')
What I ...
0
votes
1answer
20 views
Binary Search Tree 'Int object not iterable'
So I'm fairly new to programming and I am trying to make my delete function in my binary search tree to delete on the side that has the highest depth of nodes. However, I keep getting an error once I ...
-2
votes
3answers
10 views
How to convert a video to a different format using vanilla Python
I was wondering if there was a way to convert a video by using the following code:
theFile = open("File.avi", "rb")
fileInfo = theFile.read()
theFile.close()
theFile = open("NewFile.mp4", "wb")
...
1
vote
2answers
22 views
session flush is not working django
I am trying to flush all session data out when a user doesn't want to keep logged in.
in views.py
def login(request, *args, **kwargs):
if request.method == 'POST':
if not ...
0
votes
0answers
15 views
Python PIP Installing Issues
Having great difficulty installing the following:
argparse==1.2.1, beautifulsoup4==4.3.2 & wsgiref==0.1.2. I receive the same error each when attempting to install any of them:
C:\>pip install ...
2
votes
2answers
21 views
How to identify whether or not a solid circle exists in an image using python?
I'm writing a code in Python that looks for solid circles in an image and outputs the number of circles, their diameter(s) and x & y coordinates of centers of each circle.
The challenge is that ...
0
votes
2answers
19 views
Make an executable file on a mac
I have tried to gather as much information as possible before posting this question but have had little luck. (I posted the links below.)
I have a file called "Intro.py" at this path, ...
-2
votes
0answers
20 views
Python Persistent number
need some assistance to write a Persistent number program in Python to determine the smallest non-negative integer with a persistence
(715 ---> 35 ---> 15 ---> 5) of 3, then 4, then 5, then 6, then 7. ...
0
votes
0answers
5 views
Is it possible to use attributes of the final estimator of a pipeline object in scikit learn?
I have created a pipeline object which uses countvectorizer and MultinomialNB. MultinomialNB instances have an attributes named intercept_. If I try to access this attribute using the Pipeline object ...
-1
votes
1answer
17 views
Sending Emails In IMAP - Python [duplicate]
Is it possible to send emails via IMAP? I know it is easy to do with SMTP, but I am looking for IMAP only... I couldn't find any answers through a few hours of searching :/ All answers are greatly ...
-1
votes
1answer
38 views
How to consolidate Tuples in Python
Okay so I have a list of coordinates. They however are stored in tuples and some of them overlap. I am trying to consolidate them so there is no overlapping.
So: (These are both x values by the way, ...
-1
votes
2answers
21 views
Write a program that reads a file with numbers separated by commas and print those numbers to the turtle screen
Question: Write a program that reads in sequences of numbers from a file and displays them in a grid on a graphics screen. For this program, you can assume that there are 4 lines each with no more ...
0
votes
1answer
11 views
spectrum analyzer of wave files with numpy.rfft
I'm writing a script to process a wave file in Python and display a spectrum analyzer, just for nice visualization of audio files. After some reading of the doc and forums I assumed I needed to use ...
0
votes
2answers
15 views
numpy masked array fill value still being accessed
I am trying to process an image as a masked array to handle NoData areas. I decided to do a little testing first on one dimensional arrays, and am seeing something odd. here is my test code:
a = ...
0
votes
0answers
21 views
C to Python interface - Trying to pass structs
I'm currently working on an interface between C and Python and I detected a problem I'm not able to solve: I want to pass a struct to Python. Sounds simple, but somehow I keep getting a SegFault. I ...
0
votes
0answers
18 views
Python Basic Auth
Attempting to follow this tutorial on basic auth - this ends up being the final example:
import urllib2
theurl = 'http://www.someserver.com/toplevelurl/somepage.htm'
username = 'johnny'
password = ...
0
votes
1answer
14 views
How to import a text file and prep for plotting and analysis with Python
This is my first attempt of migrating from Matlab to Python 3.4 using Mac OS Yosemite. I'm stuck with what is probably a very simple issue, and here it is:
Inside a folder, I have multiple files ...
1
vote
0answers
16 views
Pandas: Group by Time, then plot density per group
I'm trying to group a data frame by time and then plot the density of a variable for each subgroup. I'm doing:
myDf.groupby(pd.TimeGrouper('AS'))['myVar'].plot(kind='density')
Here's the result:
...
1
vote
1answer
32 views
re-raise exception from method as argument
I have a method that needs some wrapping called joule, so I wrap that joule method inside a wrapper called respond (which you will see shortly):
someclass.respond(somemodule.joule(someArgument, ...
0
votes
1answer
29 views
Reading a binary file into 2D array python
I am having trouble reading a binary file in python and plotting it. It is supposedly an unformatted binary file representing a 1000x1000 array of integers. I have used:
image = open("file.dat", "r")
...
0
votes
1answer
9 views
Python / pypyODBC: Row Insert Using String and NULLs
I am pretty new to Python and have not really interacted with SQL Server and XML Parsing until this current project (might not even the best approach to take). Long story short, my IT team is very ...
-5
votes
0answers
16 views
Write a program that reads the elements of two 2D arrays from the user (python)
Write a program that reads the elements of two 2D arrays from the user and then print the summation result of the two arrays in a third array.