text stringlengths 226 34.5k |
|---|
numpy: apply operation to multidimensional array
Question: Assume I have a matrix of matrices, which is an order-4 tensor. What's the
best way to apply the same operation to all the submatrices, similar to Map in
Mathematica?
#!/usr/bin/python3
from pylab import *
t=random( (8,8,4,4) )
#t2=... |
How to make a loop repeat itself n number of times - Python 3
Question: I started programming 2 weeks ago for the first time in my life and I have
come across something that I cannot figure out. I am trying to make it so a
loop that calculates a median from a set amount of random numbers can repeat
itself many times (s... |
Do a maven build in a python script
Question: I am checking out a source for a given url using a python script and I want to
go to the downloadedFoler/src directory and perform a `mvn clean install`. I
want to do it in the same script. Thank in advance.
Answer: You can do the following:
import os
i... |
python xml parse (minidom)
Question: I need to read data from this XML file. I don´t know, how I have to read data
aaaaa, bbbbb, ccccc, ddddd, eeeee, fffff and ggggg from this XML file.
<Episode>
<Section type="report" startTime="0" endTime="10">
<Turn startTime="0" endTime="2.284" speaker="s... |
Django + Apache + mod_wsgi = Bad Request (400)
Question: I'm trying to get my app launched on VPS in `Debug=True` mode.
I'm using Django 1.6 with Python 2.7.
I tried simple wscgi script and found that it works well (basically returns
200 and "Hello world" in text/plain) to the browser. Here's my configuration:
**vir... |
Getting empty 'Ssl_cipher' with MySQLdb SSL connection to Amazon RDS
Question: I've just spent a week on the problems recorded in this question: [Why does
the CA information need to be in a tuple for
MySQLdb?](http://stackoverflow.com/questions/21315427/why-does-the-ca-
information-need-to-be-in-a-tuple-for-mysqldb)
H... |
how to extract reviews from iframeurl returned by amazon api in python?
Question: I am trying to get the `text` content of reviews of a given product in
`amazon` using its `api`. But I am not able to work it out. Here is what I
have:
result = api.item_lookup('B00062B6QY', ResponseGroup='Reviews',
... |
Inheriting a base class for nose tests
Question: I'm trying to implement an integration test framework using nose. At the core,
I'd like a base class that all test classes inherit. I'd like to have a class
setup function that is called as well as the per test setup function. When I
use `nosetests a_file.py -vs` where *... |
Fields Missing when Parsing XML with Python
Question: I am trying to collect all the data about a house using zillow's API. I am
getting some fields, yet others are coming back as null.
Here is my Python code:
from bs4 import BeautifulSoup
import requests
import urllib, urllib2
import csv
... |
Windmill AttributeError: 'module' object has no attribute 'settings'
Question: Here is the traceback:
File "./test2.py", line 44, in test_scrape
client = WindmillTestClient(__name__)
File "/usr/local/lib/python2.7/dist-packages/windmill-1.6-py2.7.egg/windmill/authoring/__init__.py", line 142,... |
Plotting a histogram on punctuation occurrence python
Question: I have thousands of sentences in series form (rows) . here's an example:
'After hearing his plea, the judge pardoned him.'
'The weather is quite sunny , though not as the other days.'
'Tom,Bill,Grace and tinkle went fishing,even though it was raining.'
... |
Reorder an array in python
Question: I want to sort an array, so it starts off at
order = [0,1,2,3,4,5] #loop around trying all columns`
and then will go through, trying all combinations of this so 1,2,3,4,5,0 etc,
and stop once it has tried all of them.
Is there anyway to do this in python?
An... |
django.contrib.auth get_user_model isn't working with monitio app
Question: i have to set up some big project to start working on it, but i don't have
access to its creator, so i have nobody to ask.
This project make use of [monitio app](https://github.com/mpasternak/django-
monitio) to handle notifications.
And i go... |
Backend API Python
Question: While implementing backend API to use backend services, I have done code as
below:
timezone_service.py:
class TaskQueueTimeZoneHandler(webapp2.RequestHandler):
def get(self):
outdict=self.request.params
logging.info("Enter In taskqueue") ... |
Load other windows when button clicked. PyQt
Question: I am trying to call another window from a button click in python 2.7 using
PyQt4. The code below opens the AddBooking dialog but immediately closes it.
Im new to Gui programming, can somebody please tell me what is wrong with my
code?
from PyQt4 impo... |
C# equivalent of Python's defaultdict (for lists) in C#
Question: What is the C# equivalent of doing:
>>> from collections import defaultdict
>>> dct = defaultdict(list)
>>> dct['key1'].append('value1')
>>> dct['key1'].append('value2')
>>> dct
defaultdict(<type 'list'>, {'key1': ['val... |
Sum 4D array efficiently according to indices contained in another array
Question: I have a 4D array, a series of cubes essentially. These cubes are mostly
filled with zeroes apart from sub-cubes of values of which I know the
locations. I need to sum all these cubes together into one cube. I can do this
simply with np.... |
String and line formatting in Python
Question: I want to make the following command to be formatted in python, in other to
comply with the 80 character per line policy:
cmd = """elastic-mapreduce --create --alive \
--instance-type m1.xlarge\
--num-instances 5 \
--supported-product mapr \
... |
subprocess.Popen using relative paths
Question: The [docs](http://docs.python.org/2/library/subprocess.html#popen-constructor)
for Popen mention that you can't specify your executable path relative to the
'change working directory' kwarg.
> If `cwd` is not None, the child’s current directory will be changed to `cwd`
>... |
Python-How to resolve TypeError
Question:
import urllib, urllib2
from bs4 import BeautifulSoup, Comment
url='http://www.amazon.in/product-reviews/B00EJBA7HC/ref=cm_cr_pr_top_link_1?ie=UTF8&pageNumber=1&showViewpoints=0&sortBy=bySubmissionDateDescending'
content = urllib2.urlopen(url).read()
so... |
Python does not find custom PyQt5
Question: As the offical pyqt5-installation in the ubuntu repositories seem to lack
support for QtQuick, I tried to install pyqt5 from source. The installation
itself seems to work correctly, but when running a python script that uses
PyQt5, python complains that it cannot find that Py... |
Web.py NameError When Importing Module in Module
Question: I am creating a web app using web.py on python 2.7.3. I have the following
folder structure:
start_app.py
/app
__init__.py
/models
__init__.py
ActionModel.py
AreaModel.py
/controllers
... |
How to divide string like this into items in Python
Question: Here is the string:
format db "this is string a", 0, 0Ah
And I am trying to split it into this:
format
db
"this is string a"
0
0Ah
Is there any way can do this in python 2.7?
Thank you!
Answer: Use... |
What happens exactly internally when I terminate my Python script using Ctrl+c?
Question: These days I am learning Python's Exception handling features deeply. I
encountered `exception SystemExit`. While reading about this from [official
Python Docs](http://docs.python.org/2/library/exceptions.html) I got question
in m... |
Python unpickling error when using base64encoding
Question: I am trying to use pickling and I can't. It seems that I am doing something
wrong. What is it? (using python 2.7)
In [2]: import cPickle as pickle
In [3]: arr = []
In [4]: tuple = ('name', 'surname', 'addr', 'area')
In... |
wxPython threading downloads
Question: I need to download a list of urls in a wxPython application, but I'm really
new to threading, could anyone show me a working example of how to download
links and put the output in a wx control.
Answer: It would have been nice to see what you had done to at least try to accomplis... |
Python range(%d) % sides
Question: I am trying to make a program, that uses the turtle module using Python
2.7.5+. The user can input a integer so I want to use that number as a
argument for range()
Here is my code so far:
import turtle
import time
sides = int(raw_input("Enter the amount of side... |
How to interact with ssh using subprocess module
Question: I'm trying to spawn an ssh child process using subprocess.
I'm working on Python 2.7.6 on Windows 7
here is my code:
from subprocess import *
r=Popen("ssh sshserver@localhost", stdout=PIPE)
stdout, stderr=r.communicate()
print(stdou... |
Python Pdb giving me a tracback and won't run
Question: I set the `Pdb` debugger in my file as I always do like so `import pdb;
pdb.set_trace()` and now I keep getting this traceback. I'm not sure what is
the issue, and I don't see anything online about this anywhere.
Traceback (most recent call last):
... |
symbol not found when import PySide QtGui in python and mac 10.9
Question: My computer was damaged and forced me to buy a new Mac. I was using MacOS 10.6
with python 2.7.2, PySide 1.0, and Qt 4.7 before. I have setup the new machine
by transferring everything from the old computer to the new one. And things
have starte... |
Insert Python List into a single column in mySQL Database
Question: Hi I am trying to insert a python list into a single column but it keeps
giving an error on the syntax. New to this. Appreciate any help. Thanks.
from time import time
import MySQLdb
import urllib
import re
from bs4 impor... |
Issuing commands to psuedo shells (pty)
Question: I've tried to use the subprocess, popen, os.spawn to get a process running,
but it seems as though a pseudo terminal is needed.
import pty
(master, slave) = pty.openpty()
os.write(master, "ls -l")
Should send "ls -l" to the slave t... |
Finding the nth smallest number in a list?
Question: i need a efficient way of getting the nth smallest number AND its index in a
list containing up to 15000 enties (so speed is not super crucial).
I sadly can't use numpy or any other non-standard library.
Im using Python 2.7
Answer: use `heapq.nsmallest` (and `enu... |
celery throws unicodedecodeerror when try to start
Question: I want to run example code(tasks.py) from official tutorial:
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
@app.task
def add(x, y): return x + y
I used command "celery -A tasks worker --log... |
How do I make python encrypt both uppercase and lowercase?
Question: Basically I want the ciphered phrase as the output with both uppercase being
ciphered to uppercase and lowercase being ciphered to lowercase but not any
spaces or symbols are ciphered. It can encrypt a paragraph consisting of all
upper case and a para... |
Linux - Weird Python Output
Question: When ever i mistype or do a error into the console the following message come
up:
Traceback (most recent call last):
File "/usr/lib/python3.3/site.py", line 629, in <module>
main()
File "/usr/lib/python3.3/site.py", line 614, in main
... |
Can't get un-stacked bar plot in python pandas
Question: This is weird. I just can't seem to get unstacked bar plot in python pandas
(unlike pandas official guide). The bars just seem to be overlapped, instead
of placed sideways. Any clue why it would be?
df.plot(kind='bar',stacked=False, figsize=(20,15)... |
Python: Can't fix IndentationError: expected an indented block
Question: I've messed around with this code in python as much as possible and still
can't seem to get it to work
#!/usr/bin/env python
from time import sleep
import os
import RPi.GPIO as GPIO
GPIO.setmode (GPIO.BCM)
G... |
How to read code file that are in the Python memory?
Question: This is the error/traceback I'm actually getting:
Traceback (most recent call last):
File "/home/apache/tactic/src/tactic/ui/panel/custom_layout_wdg.py", line 619, in process_mako
html = template.render(server=my.server, search=... |
OPC with Python 3.3
Question: I'd like to read the tags from my OPC server (kepware) with Python 3.3 I have
found the openopc project at the sourceforge, but it seems it doesnt work with
Python 3.3
Do I have other options here?
Answer: If your Python program runs under Windows platform, you can use QuickOPC
(<http:/... |
Xcode 5 iPhone app; all my '[' and ']' match, but "parse expected ']' " still comes up
Question: i'm new and learning from a tutorial, i've coded in _python_ before so i have
mercilessly hunted for the additional '**]** ' it claims it needs… and even
when i put it in it then says, it's unexpected and want to delete it,... |
Error while using dpkt in python
Question: I'm writing some code to parse a pcap file in python as follows:
#!/usr/bin/env python
import socket
import dpkt
import sys
import pcap
pcapReader = dpkt.pcap.Reader(file("clients.pcap", "rb"))
for ts, data in pcapReader:
ether = ... |
Flatten (an irregular) list of lists in Python respecting Pandas Dataframes
Question: This is a recursive question here on Stackoverflow, yet the solution given
[here](http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-
of-lists-in-python?answertab=active#tab-top) is still not perfect. Yielding is
sti... |
Python Selenium WebDriver. How to check/verify that drop-down menu with suggested results is displayed?
Question: I wanna make sure that this drop-down menu with suggested results is displayed
when I enter something into search field.

Here is my scri... |
Memory error at python
Question:
from __future__ import division
import dataProcess
import csv,re
from collections import OrderedDict
import itertools
#######################################################################################
# Pruning of N-grams depending upo... |
Accessing enumaration constants in Excel COM using Python and win32com
Question: I'm using python 2.7 win32com module to load an MS Excel worksheet from
Python:
book = xlApp.Workbooks.Open("myFile.xls")
sheet = book.Sheets(1)
Many methods and properties of Range, Worksheet etc use enume... |
Sending High Importance email through Outlook using Python
Question: Using win32com.client package, I'm able to send an HTML email using outlook
through Python. However, I'm having a hard time figuring out how to mark an
email "high priority" or "high importance".
Here is the code I'm using to successfully send out an... |
StringVar bound to an Entry doesn't update Entry value
Question: I'm starting with GUI in Python and Tkinter and want to make a small window
that load an image from a file and show the path of the file and also de
image. Until now, I've got my window and the button to pick the image
(_tkinter.filedialog.askopenfilename... |
Paragraph Matching Python
Question: **Background information**
I have a Python script which generates word documents with the `docx` module.
These documents are generated based on a log and then printed and stored as
records. However, the log can be edited retroactively, so the document records
need to be revised, and... |
Numba code slower than pure python
Question: I've been working on speeding up a resampling calculation for a particle
filter. As python has many ways to speed it up, I though I'd try them all.
Unfortunately, the numba version is incredibly slow. As Numba should result in
a speed up, I assume this is an error on my part... |
How to remove character from tuples in list?
Question: How to remove "(" ,")" form
[('(10', '40)'), ('(40', '30)'), ('(20', '20)')]
by python?
Answer: Straightforward, use list comprehension and literal_eval.
>>> from ast import literal_eval
>>> tuple_list = [('(10', '40)'), ('... |
How to do linear regression, taking errorbars into account?
Question: I am doing a computer simulation for some physical system of finite size, and
after this I am doing extrapolation to the infinity (Thermodynamic limit).
Some theory says that data should scale linearly with system size, so I am
doing linear regressio... |
Selenium webdriver screenshot not being taken from django
Question: I have a functional test 'y1.py' which I have exported from the selenium IDE.
It looks like:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from sele... |
Matplotlib Version
Question: Having my system prepped with homebrew and using `pip install matplotlib`
after successful installation of numpy and scipy, I'm getting a successful
installation. Then, running
$ python
Python 2.7.6 (default, Jan 30 2014, 20:19:23)
[GCC 4.2.1 Compatible Apple LLVM 5.... |
Repeating rows in numpy according to a vector of indices
Question: Suppose I have a matrix B:
B = [
[0, 1, 2],
[2, 3, 4],
[5, 6, 7]
]
and a vector a:
a = [0,0,1,1,2]
I need to define a new vector C such that it repeats the rows in B as
specified by a... |
Passing variable to another Python Script
Question: I am having difficulty passing a variable from one function to another
function in another python script. I have read the other answers but they have
not really helped on this subject.
This is the first file I want to send the variable to( some code omitted for
clari... |
Python file copying using regex
Question: I have a large log file. I want to extract the lines containing
`java/javax/or/com` followed by a `./:`. For every line like this, I want to
extract some of the corresponding lines which are stack traces and starts with
`at`. For example:
Line1: java.line.somethi... |
Integrating New Relic with Tornado app with gunicorn as a process manager
Question: I want to use New Relic to monitor errors in my Async Tornado app with
gunicorn as a process manager.
When I try to make a request after integrating with New Relic I get the
following error File "/Library/Python/2.7/site-
packages/newr... |
How to uninstall manually openerp module
Question: I have installed a module on openerp v7 that I would like to uninstall.
Using the interface fails, i get an error during the uninstall process.
Is there a 'manual' way to uninstall a module ? Is it sufficient to remove the
module folder under `addons/` or is there an... |
How to test session in flask resource
Question: I'd like to test a resource. The response of that depends on a parameter in
session (logged) To test this resource, I've wrote those tests:
import app
import unittest
class Test(unittest.TestCase):
def setUp(self):
self.app ... |
Faster to add all items to an array then write the array to file, or faster to write the item to a file and then add to array one at a time?
Question: So right now I have this (in Python 2.7):
if y == ports[0]:
Array1.append(x)
elif y == ports[1]:
Array2.append(x)
elif y == ports[... |
Vim plugin to toggle Python function/method arguments between single- and multi-line
Question: I'm looking for a Vim plugin that can take a single-line statement like this:
foo = self.some_method(param1="hi", param2="there")
and turn it into this:
foo = self.some_method(
para... |
Installing PyQuery Via Pip
Question: I'm attempting to install `PyQuery` via `pip` but I'm getting an error I do
not understand. The command I used was:
sudo pip install pyquery
I get the output below:
Requirement already satisfied (use --upgrade to upgrade): pyquery in /usr/local/li... |
Relative imports with unittest in Python
Question: I am trying to use Python unittest and relative imports, and I can't seem to
figure it out. I know there are a lot of related questions, but none of them
have helped so far. Sorry if this is repetitive, but I would really appreciate
any help. I was trying to use the sy... |
Python ISRIStemmer for Arabic text
Question: I am running the following code on IDLE(Python) and I want to enter Arabic
string and get the stemming for it but actually it doesn't work
> > > ">>> from nltk.stem.isri import ISRIStemmer
>>>
>>> ">>> st = ISRIStemmer()
>>>
>>> ">>> w= 'حركات'
>>>
>>> ">>> join = w.de... |
Does tuple() copy the elements of the argument?
Question: In python, does the built-in function `tuple([iterable])` create a tuple
object and fill it with copies of the elements of "iterable", or does it
create a tuple containing references to the already existing objects of
"iterable"?
Answer: `tuple` will iterate t... |
Contour plot from data in a vtk file using Python
Question: I have a set of data stored in a VTK file which represents a cut through a
domain with scalar point data in an array. I am trying to produce a contour
plot of said scalar to make it look somewhat like the attached picture made
using ParaView. I'd rather stick ... |
python: can't work out why len function() is behaving not as expected
Question: i have been working on a python tutorial and have come across a problem which
i simply cannot work out. google has not turned up anything specific and after
a few hours away and much trial and error i still cannot work it out.
anyway, the ... |
create an echo server
Question: I am new to python and trying to code. I want to create simple echo server _ie
whatever I input to the client will simply be echo back by the server_ and if
the client user press enter without writing anything then the server will
disconnects. It may be very simple but I lacks logic here... |
Can't bind with port 21 on Python
Question: I'm trying to build a simple ftp server with python, but I get an error: "An
attempt was made to access a socket in a way forbidden by its access
permissions" As I understand, it's because of the port number, but what should
I do?
Here is the code:
import sock... |
sending QTreeWidgetItem to a function with python
Question: I'm trying to make a program using Python, Komodo and QT4.
I'm trying to send a QTreeWidgetItem to a function after it was selected by
the user with the mouse. All I was able to do is to move the position of the X
and Y of the selected point by the mouse. Can... |
Pyocr doesn't recognize get_available_tools
Question: I'm using <https://pypi.python.org/pypi/pyocr/0.1.2> for text recognition from
images my script is as follows :
from PIL import Image
import sys
import pyocr
import pyocr.builders
tools = pyocr.get_available_tools()
if len(too... |
How to "un-export" something in Python
Question: Following a django tutorial, I entered these two lines in my terminal:
export PYTHONPATH=$PYTHONPATH:/var/www/djangoapp:/var/www/djangoapp/app
export DJANGO_SETTINGS_MODULE=app.settings.settings
I did't know what exactly I was doing. The problem ... |
iTunes win32com Python - AddTrack not working
Question: I've been using the following code to try and create a new playlist in iTunes
and a song from the main library - its example code i've found but i keep
getting the following error when it runs. I've had a look through the iTunes
COM interface documentation and it ... |
Searching in csv files
Question: How do I search between the first two commas in a csv file? E.G: CSV FILE:
name, surname, age , gender
How do i only search for the first two, name and surname with the users input?
this is what i have. I am looking for the user to search only by a name or
surn... |
How to find all ways from up to down in list use python
Question: Python v.3.2.3:
Need to find all path in this `list[]`, but go down accept only `(↓, ↓+right)`
. In finish need create list of `list(all paths)` from `up([0][0])` to
`down([6][x])`.
Example(list):
[[30], [27, 84], [25, 33, 11], [31, 54,... |
Encoding issue for Python tool Unidecode on CL
Question: I need to convert unicode files to ascii. In case, a letter doesn't exist in
ascii, it should be converted to it's closest ascii representation. I'm using
the Unidecode tool for it (<https://pypi.python.org/pypi/Unidecode>). It works
fine when I use it in the Pyt... |
How to get the output from .jar execution in python codes?
Question: I'm programming the python module that executes SQL to DBMS and retrieves
data. I'm trying to use jdbc jar files instead of native DB drivers. I'm
wondering how to executes jar file in python and get output from jar
execution. And I'd like to know how... |
Inter Document Similarity: Cosine distance
Question: **Updated Question:**
According to **"perimosocordiae"** s solution I found out the cosine
similarity between 2 documents. I have tried to use the solution to find out
similarity between 2 Files. But again an error arises in test(), which is
Traceback... |
Django runserver error (sqlite2 & sqlite3)
Question: I just installed Django and I'm following this tutorial: [Django
tutorial](http://www.djangobook.com/en/2.0/chapter02.html.)
When I type "python3.3 manage.py runserver" this happens:
ninaolo@ninaolo-VirtualBox:~/Documents/Django-projekt/testprojekt$ p... |
wx.ProgressDialog + py2exe leads to application crash
Question: This simple code runs very well :
import wx
app = wx.App(0)
frame = wx.Frame(None)
test = wx.ProgressDialog('Test', 'Test', maximum = 20, parent = frame, style = wx.PD_CAN_ABORT)
app.MainLoop()
However, when compiling/p... |
python numpy assigning by boolean indexing error "TypeError: array cannot be safely cast to required type"
Question: In the last line of the following code I get an "TypeError: array cannot be
safely cast to required type". Can you help?
Let me explain the code a bit. `randin()` function helps me get an array with
ele... |
SVD - Matrix transformation Python
Question: Trying to compute SVD in Python to find the most significant elements of a
spectrum and created a matrix just containing the most significant parts.
In python I have:
u,s,v = linalg.svd(Pxx, full_matrices=True)
This gives 3 matrices back; where "s" cont... |
How to return a character from standard input on OS X in Python?
Question: For a Python project that I'm working on I need to tell the user to insert a
character and return its value in ASCII code without having to press enter to
commit the key.
It must also read the input only if my program is the active application,... |
python how do I determine screen size
Question: I need to resize an image. The original is 1024x768. My laptop screen is set
to 1366x768. When I go to view the image the bottom is always cut off. I'm
guessing it's because the image is 1024x768 but the image size doesn't take
into account the box/window the image sits i... |
Python Class Fields
Question: I am new to Python having come from mainly Java programming.
I am currently pondering over how classes in Python are instantiated.
I understand that `__init__()`: is like the constructor in Java. However,
sometimes python classes do not have an `__init__()` method which in this case
I as... |
How to use random.random() in python
Question: Hello I am working on a problem set and everything has been going well till I
got to random.random() the instructions are to (Use random.random() to print
10 float numbers from from 21.0 to 30.0 inclusive) however what I am stuck on
is on printing the 10 float numbers a ex... |
Natural Join Implementation Python
Question: I am working on implementing natural join in python. The first two lines show
the tables attributes and the next two lines each tables' tuples or rows.
Expected Output:
[['A', 1, 'A', 'a', 'A'],
['A', 1, 'A', 'a', 'Y'],
['A', 1, 'Y', 'a', 'A'],
... |
Passing arguments to python unittest
Question: I have a functional test 'y1.py' which I am trying to pass arguments to, from
within a python/django function. Inside the calling function I have:
import unittest, sys
import ft1.y1
ft1.y1.testVars = [1, 2, 3, "foo"]
unittest.main(module=ft1.y1, ... |
TypeError when passing bytearray to C++ extension
Question: Python code:
image = urllib2.urlopen('http://localhost/test.png').read()
bytes = bytearray(image)
print [myext.do_stuff(bytes, mode=1)]
C++ code:
static PyObject *
do_stuff(PyObject *self, PyObject *args, PyObje... |
OpenMP, Python, C Extension, Memory Access and the evil GIL
Question: so I am currently trying to do something like A**b for some 2d ndarray and a
double b in parallel for Python. I would like to do it with a C extension
using OpenMP (yes I know, there is Cython etc. but at some point I always ran
into trouble with tho... |
Can't modify global dict variable using mutliprocessing in python
Question: I try to use multiprocessing to process numpy array. But I don't know how to
return the process result back to the dict variable.
Use the comments out code can produce what I expected. But when I try to use
multiprocessing, I can't get anythin... |
Combine two lists of lists into a dictionary python
Question: I'm not experienced in programming and I have a problem with combining two
lists of parsed sentences (=list within list) into a dictionary. I'm using
python 2.6.6
I have two lists of sentences, one in English and the other one in German. The
sentences corre... |
resize a 2D numpy array excluding NaN
Question: I'm trying to resize a 2D numpy array of a given factor, obtaining a smaller
array in output.
The array is read from an image file and some of the values should be NaN (Not
a Number, np.nan from numpy): it is the result of remote sensing measurements
from satellite and s... |
Django Admin redirects to 500 error
Question: I am getting a 500 error when i login to the django admin interface.
I have a ubuntu server 13.10 running nginx uwsgi mysql for my database.
ive set it up following [this
tutorial](http://blog.richard.do/index.php/2013/04/setting-up-nginx-django-
uwsgi-a-tutorial-that-act... |
accessing ArgumentParser variable with environment variable
Question: How do I access the prog variable of the
parser = argparse.ArgumentParser(prog='ipush',
description='Utility to push the last commit and email the color diff')
parser.add_argument('-V', '--version', action='version'... |
python social auth redirect to an error page conditionally
Question: Am using python social auth with django to create authentication and
registration via social media. I've defined the
> LOGIN_ERROR_URL = '/account/auth-failed/'
it works well when there is a problem, it would redirect there correctly. Yet,
I want to... |
creating a object in a method in python: invalid syntax
Question: I'm trying to make a little program to create and administrate accounts with a
bank. The code is written in German, I wrote the translation in the comments.
Every time I'm trying to compile the program the compiler says 'invalid
syntax', but doesn't high... |
Python alternative to import
Question: I've got the following code:
def main():
#init
#Load config.
import localconfig
print localconfig.name
#update mac adress db, if at all possible:
try:
from maclist import maclist
except:
... |
Getting Started with C development and GTK+
Question: I'm really a Python developer exclusively, but I'm making my first foray into
C programming now, and I'm having a lot of trouble getting started. I can't
seem to get the hang of compilation and including libraries. At this point,
I'm just identifying the libraries t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.