text stringlengths 226 34.5k |
|---|
Repeating an algorithm as many times as the user requires (PYTHON 3.3.2 GUI)
Question: I'm trying to repeat this algorithm and use the values in my code, please
help!!!
import random
def dice_roll(number):
if number == 12:
number = random.randint(1,12)
print(number)
... |
PIL: AttributeError: 'NoneType' object has no attribute 'show'
Question: I'm trying to use PIL to show an image loaded from a list of numbers.
My entire code looks like this:
from PIL import Image
import os, sys
L = 4 #resolution increase
LR_DIM = (2592, 1944)
HR_DIM = (LR_DIM[... |
Google App Engine deferred.defer() error 404
Question: I'm trying to get running a task in the Task Queue using deferred.defer(). The
task is added to the default task queue, but the task fail with a 404 error.
This is the handler:
import webapp2
import models
import defer_ajust_utils
... |
Haskell: Appending to a list from multiple locations in a program
Question: I would like to have a list that may be updated (appended to) from more than
one location in the code. Since in haskell, [`calling a function once is the
same as calling it twice and discarding the result of the first
call`](https://www.fpcompl... |
Python 2 raw_input() : EOFError when reading a line in WINDOWS 7 command prompt
Question: NOTE: Many of the same questions have been asked about python raw_input() in
**sublime text**. This question is **NOT** about sublime. The python code is
called in Windows command prompt which unlike the sublime terminal does
supp... |
`Query.count()` woes with Flask-SQLAlchemy and multiple binds
Question: # Abstract
I am having trouble using multiple binds with Flask-SQLAlchemy. In particular,
the `count()` method on query objects doesn’t seem to work.
# Particulars
My Flask application works on a PostgreSQL database. Additionally, it also
retrie... |
Calling isinstance in main Python module
Question: There is a strange behavior of isinstance if used in `__main__` space.
Consider the following code
a.py:
class A(object):
pass
if __name__ == "__main__":
from b import B
b = B()
print(isinstance(b, A))
b.p... |
Python pyserial slow and crashes after given period of time
Question: When I use Python’s pyserial to obtain voltage and time information from an
Arduino, the Python with Pyserial appears to be slow. When I look in the
Arduino serial monitor, everything is fine, the time and voltage values are as
expected and can go on... |
Install python, pygtk in user's space
Question: I am trying to install python with pygtk in my ubuntu system.
I don't have root access so I need to install all the packages locally say
/home/user/local/lib
I am able to install python, but I am not able to link other
packages(pygobject, pygtk, etc) to the locally inst... |
python string to date ISO 8601
Question: I am converting many obscure date formats from an old system. The dates are
unpacked/processed as strings and converted into ISO 8601 format.
This particular function attempts to convert YYMMDD0F to YYYYMMDD -- function
name says it all. Dates from the year 2000 make this messy... |
how to install packages o python?
Question: Mac OSX 10.6.8 Python 2.7
Hi guys,
I just recently started programming with Python using the "Think Python" by
Allen Downey. In Chapter 4, the first case study, he recommends to install a
package called swampy...so basically I´m stuck here. For trouble shooting
Downey recom... |
global name logger is not defined thru classes?
Question: I cant get logger as a global name... I tried it inside a normal script, and
later trying to debug inside the python cli, but its out of my reach
apparently...
(as you will notice, I tried to define logger global everywhere, but also
without that, no success)
... |
IronPython Remote Debugging with PTVS
Question: i've implemented IronPython in my C#-Application successful. I store all my
scripts in a database and load them when they are needed. Now i want to debug
my Python-Code with the PTVS. But always when i try to connect with the remote
debugger to my application the visual s... |
Apache hangs with Django / Matplotlib app
Question: new StackOverflow user here. I need help with an Apache freezing problem. I
have a WAMPServer setup on Win 7 64-bit and am working with python / django /
mysql / mod_wsgi / matplotlib, experimenting with dynamically rendered images.
I am using Apache to serve static f... |
Python PyQt: How Run While Loop Without Locking Main Dialog Window
Question: Pressing Ok button will run while_loop() method which prints some message on a
screen.
While **while_loop()** method is running the main dialog becomes
irresponsible. It's interesting that even after a dialog window is closed the
function its... |
Categorize and calculate something in python
Question: I have following input file
O 2.05151 39.51234 0.00000
O 32.69451 1.48634 8.31300
O 10.53351 21.63634 7.95400
O 30.37451 20.74134 0.99700
Si 8.06451 19.19434 10.21700
Si 32.03251 42.98634 21.23900
... |
ArgumentParser object has no attribute 'add_option' on passing flags
Question: Day three of learning python.
I'm attempting to understand how to pass flags from the command line and call
a function with that flag. However, I'm getting the following error:
Traceback (most recent call last):
File "m... |
Kill a process and all its threads from the same process
Question: I am spawning a python process using MultiProcess library and within it I am
spawning around 100 threads( of 3 types each performing a separate function
and using a Queue).
I want my process to neatly terminate when a db flag is raised killing all the
... |
Good approach for updating the GUI continuously in wxPython using threads?
Question: I am working on a GUI app using python v2.7 and wxPython v3.0 on windows 7 OS.
I have to update my GUI continuously which contains lots of panels. Each
panels contains a `wx.StaticText`. I have to update these `wx.StaticTexts`
continuo... |
Passing values from bash to python
Question: I am trying to implement bash with python can anybody help me or teach me on
what should be done.Thanks my code is
import io
val=os.system("echo 'sdfsfs'") #for example
print(val)
Answer:
>>> import subprocess
>>> subprocess.c... |
Drawing a 2D function in matplotlib
Question: Dear fellow coders and science guys :)
I am using python with numpy and matplotlib to simulate a perceptron, proud to
say it works pretty well.
I used python even tough I've never seen it before, cause I heard matplotlib
offered amazing graph visualisation capabilities.
... |
Pip is already installed: but I am getting no module named lxml
Question: I have installed lxml with pip. But when I run a script that uses lxml, I get
"no module named lxml." Why might this be? How do I fix it?
(venv)prompt$ sudo pip install lxml
Requirement already satisfied (use --upgrade to upgra... |
What is wrong with my linked list?
Question: I am trying to create a class for nodes (it's suppsoed to be a system for a
queue) to `import` in another program. I know that the other program is
working fine since it works when `import`ing another type of queue that uses
the same function names(that is based on Pythons r... |
Selenium doesn't return after starting Chrome but returns after starting Firefox?
Question: I am trying to execute the following code in Python with Selenium:
def create_browser(first_page=None):
print "Starting"
browser = webdriver.Chrome()
if first_page:
browser.get(... |
Why does pytz correctly adjust time & offset when crossing TZ & DST boundaries but not the TZ name?
Question: I have reviewed several `pytz`-related questions here, but none seems to
address the exact problem I'm seeing.
Following the [pytz documentation](http://pytz.sourceforge.net/), here's a
loop to print the curre... |
Searching a List of Objects for those Objects with a Particular Member Variable set to a Value?
Question:
import string
import random
class Foo(object):
def __init__(self, bar):
self.bar = bar
foos = []
for i in range(1,101):
f = foo(random.choice(string.letter... |
Inspect code of next line in Python
Question:
# script.py
greeting = "hi"
import inspect; import traceback; print traceback.format_stack(inspect.currentframe())[-1]
print greeting
The code on the fourth line of the script prints out the file name, line
number and the current line:
... |
How do you share a variable between two processes in Python?
Question: I have two processes, one adds jobs to a queue and the other takes them off
the same queue and runs them. This should work as expected and I'm not sure
why the `worker` never gets any jobs. Here's my code:
from multiprocessing import ... |
How can I convert a XLSB file to csv using python?
Question: I have been provided with a xlsb file full of data. I want to process the data
using python. I can convert it to csv using excel or open office, but I would
like the whole process to be more automated. Any ideas?
**Update:** I took a look at this
[question](... |
Running Selenium Webdriver headlessly using Cron
Question: I am trying to execute my Selenium Scripts through cron headlessly using Xvfb.
The code of shell script looks something like this
export PATH=$PATH
Xvfb :10 -ac &
gnome-terminal -e export DISPLAY=:10 &
gnome-terminal -e firefox &
... |
How do I improve my code for Think Python, Exercise 7.4 eval and loop
Question: The task:
> Write a function called `eval_loop` that iteratively prompts the user, takes
> the resulting input and evaluates it using `eval()`, and prints the result.
>
> It should continue until the user enters `'done'`, and then return t... |
Create pixel square and present later
Question: I’ve started working with Python and SDL2 a short time ago to program my
psychological experiments. My question, therefore, is probably very basic. I
would like to create a square filled with random pixels of two different
colors and show it in the middle of the screen. I... |
extracting tuples based on values in python
Question: I have a list of tuples with following format ("key","value"), I need to
extract keys with highest & second highest values & store them, how do I
achieve this in python ?
Answer: Use
[`heaq.nlargest`](http://docs.python.org/2/library/heapq.html#heapq.nlargest):
... |
/etc/aliases using pipe to run script return error (mailer=prog, dsn=5.3.0, stat=unknown mailer error 2)
Question: I would like to get any advice for my issue to run script on /etc/aliases. At
first, here are my envirements/script.
* OS : centos 6
* script : python 2.6.6
* mail : sendmail-8.14 / dovecot-2x
* p... |
python getting syntax error in except
Question: I am new to python and just been playing with the database API. I am getting
an invalid syntax error in the exception except block comma. I can't figure
out any syntax mistakes. Below is the code I am using
import time
import MySQLdb
import sys
... |
Python's support for hexadecimal escapes in the replacement text
Question: Could not found a corresponding PEP or a bug for one problem in Python's `re`
module.
Does anyone know if the following is planned to be fixed?
From [regular-expressions.info](http://www.regular-
expressions.info/replacenonprint.html):
> Pyth... |
python - using Selenium logging in
Question: I followed the accepted answer's solution at: [How to use Selenium with
Python?](http://stackoverflow.com/questions/17540971/how-to-use-selenium-with-
python)
I am trying to log into coinbase <https://coinbase.com/signin>
Here is my code
from selenium import... |
Parsing Tex using python re library
Question: I want to parse the following part of a .tex file
\section{a}
some random lines with lot
of special characters
\subsection{aa}
somehthing here too
\section{b}
I want the content within `\section{a}` and `\section{b}` inclusive so i ... |
TypeError: open() takes 0 positional arguments but 2 were given
Question: Here is the code:
def save():
f = open('table.html', 'w')
f.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n")
f.write("<html... |
Python Files, adding values to/from a list
Question: I am trying to add a value to a list from a file, and then be able to add the
values from the file to the list. This is what I have:
L = []
def readFile(L):
ui = input("Please enter your file name:")
r = open(ui, 'r')
... |
Python 3.x dynamically group elements in 2d list by common elements in list
Question:
[('20bgx6', 'HQ', 'Head Quarters'),
('2040bl', 'NVA', 'North Vietnamese Army '),
('2040bl', 'HEAT', 'High Explosive Anti Tank '),
('2040bl', 'HEAT', 'High Explosive Anti Tank '),
('202kon', 'HEAT', 'High Explos... |
Python Terminal GUI - like functionalities
Question: How can I make a console GUI of sorts?
It's important to note that I will be changing the text in some of the spots,
and this is why I can't have it just print to the screen. It would be fine to
use other modules, but I'd prefer not to have to. Here's an ASCII mocku... |
Python: Remove elements from the list which are prefix of other
Question: Fastest (& python) way to get list of elements which do not contain any other
elements as their prefix.
(Elements can be in any order, for the sake of clarity in explanation elements
are kept kind of sequential here, so if needed sorting has to ... |
Python Bottle - Inline IF statements in Template
Question:
Make = <SELECT name="where_make">
% for make in makes:
<OPTION value="{{make}}"
% if make == defaults['make']:
selected="selected"
% end
>{{make}}</option>
... |
Supporting the "with open" syntax without using contextlib.closing()
Question: I really like the syntax "with open('in_file'') as f". I want to use that
syntax for my own resources which must be opened and closed.
However, I do not understand how to change my open() method to enable the
'with' syntax. I can (and do) u... |
Python circular import, `from lib import module` vs `import lib.module`
Question: I have two python modules, `a.py` and `b.py`, both of which are in `lib/`
relative to the current directory. Suppose each module needs the functionality
of the other.
**a.py:**
import lib.b
...
**b.py:**
... |
Facing an error in program of image capturing and processing using opencv(cv2) and python
Question: In the following program, it captures and processes image runtime. But I am
facing a lot problems in the code. The first problem is, when camera is
initialized for the first time and if it is unable to detect red colour ... |
How can I use monkey patching in Python to replace a specific argument?
Question: I want to use monkey patching to change all statements such as `time.sleep(5)`
to `myServer.sleep(5)`. How can I realize it? Thank you very much!
import test
import subprocess
import ast
import os
import tim... |
I don't see why this code is not working! can someone please tell me what i am doing wrong?
Question: I keep getting an error, but i dont see it.. I am new to programing and if you
explane me the code, please dont assume I know too much.
#!/usr/bin/env python
# Name:
# Student number:
'''
... |
Retrieving whole genome genbank files for some organism using Biojava or Biopython
Question: does anyone have an idea how to automatically search and parse gbk files from
FTP ncbi using either BIopython or BioJAVA. I have searched for the utilities
in BIojava and have not found any. I have also tried BioPython and here... |
Fortran - Cython Workflow
Question: I would like to set up a workflow to reach fortran routines from Python using
Cython on a Windows Machine
after some searching I found : <http://www.fortran90.org/src/best-
practices.html#interfacing-with-c> and <http://stackoverflow.com/tags/fortran-
iso-c-binding/info>
and some c... |
Parsing XML string with python
Question: I have an XML string that I take from a wsdl web service. I tried to parse it
with elementTree but it is only for files. I tried to save it in a file in
order to parse it but it says I don't have permission to open the file. So I
used this solution that I found in stackoverflow:... |
Python - Exhaust map of multiple iterables
Question:
a=['1','2','3']
`map(int,a)` can be exhausted using list to yield output:
list(map(int,a))
output: `1,2,3`
* * *
a=['1','2','3']
b=['1','2']
How do I exhaust the following:
map(int,a,b)
An... |
Is it possible to make grequests and requests_cache work together?
Question: Look at this code:
import requests
import grequests
import requests_cache
requests_cache.install_cache('bla')
urls = [
'http://www.heroku.com',
'http://python-tablib.org',
'http://htt... |
Why is this program not writing the final variable string to it's destination text file?
Question: I'm almost there with using some Python code to pull down stock data strings
passed to it from SAS to build a text file to read back into SAS, but the
final output text file remains at 0 bytes, despite the code running wi... |
Trying to produce automated daily call reports through RingCentral either by webscraping or by emailing the .csv export
Question: Since RingCentral (VOIP) phone provider does not provide any call statistic
reporting, I am looking for an alternative.
I want to automate this as much as possible, and avoid having to go t... |
Can't install python mysql library on Mac Mavericks
Question: It was working like a charm before the update from Mountain Lion.
After the update it is broken and I cannot get the environment up again.
Does anybody know how to fix this?
The error is bolded, below.
fedorius@this:~$ pip install mysql-pyt... |
rescale and normalize x axis numbers in python3.2 and matplotlib
Question: I am working in python 3.2 and matplotlib.
The numbers of x-axis are between 0 and 1000000.
In my plot, the numbers of x-axis are long and overlap each other.
I want to re-scale and normalize them between 0 and 10 and also show the unit
(such... |
subprocess.Popen stdin read file
Question: I'm trying to call a process on a file after part of it has been read. For
example:
with open('in.txt', 'r') as a, open('out.txt', 'w') as b:
header = a.readline()
subprocess.call(['sort'], stdin=a, stdout=b)
This works fine if I don't read any... |
Read a binary file *.SRS (Solar Radio Spectrograph)
Question: I wanna read a binary file (K7120127.SRS) with caractristhics detailed in the
word file (Documentacion SRS DATA.doc) ,2.2. chapter, that adding in the next
link
[https://drive.google.com/folderview?id=0B_NlxFaQkpgHb00yTm5kU0MyaUU&usp=sharing](https://drive.... |
Can't get hello world in django
Question: I tried writing the hello world program in django but i get didn't get the
expected outcome. Please help- 2nd day stuck here. My Python version 2.7.
Django 1.6.2
**Directory list:**
1. mysite
* manage.py
* mysite
* _init_.py
* _init.pyc
* se... |
MySQLdb windows create database
Question: I am trying to create a `MySQL database` in `python`.
I am using `MySQL db`.
Currently, here is what I do:
import MySQLdb
db1 = MS.connect(host="localhost",user="root",passwd="****")
Everywhere I go it seems that everybody assumes that you know ho... |
Reportlab error: 'Table' object has no attribute '_colpositions'
Question: I'm trying to teach myself reportlab from the user guide. The document I need
to create is just formatted text that needs to go in specific places on the
page. In the following snippets, table_data is a list containing 3 strings. I
imported Tabl... |
Pythonic way to simple array handling
Question:
import numpy as np
data = np.array([[2,0,1,2,0],[0,1,2,0,1],[2,0,1,2,2]])
I require the following threes as separate variables
class0 = np.where(data==0)
class1 = np.where(data==1)
class2 = np.where(data==2)
I knew how to write ... |
multiply string element per int element from two arrays Java
Question: I am learning Java and looking for a comprehensive code of multiplying the
elements from 2 arrays, possibly without importing anything to achieve it.
In Python it's quite easy:
a=['a','b','c','d']
b=[1,2,3,4]
[x*y for x,y in ... |
Exceptions are not handled in assertRaise()
Question: I am having trouble and difficulties with Pilgrim's Dive into python 3 Unit
Testing chapter. I've run the exact same code in romantest2.py. Exceptions are
not being handled in the code provided on the examples. I have deduced the
example on the book into a smaller s... |
How to extract character ngram from sentences? - python
Question: The following `word2ngrams` function extracts character 3grams from a word:
>>> x = 'foobar'
>>> n = 3
>>> [x[i:i+n] for i in range(len(x)-n+1)]
['foo', 'oob', 'oba', 'bar']
This post shows the character ngrams extraction... |
inspect.isfunction doesn't work for all modules?
Question: I'm attempting to use the answer to [Is it possible to list all functions in a
module?](http://stackoverflow.com/questions/4040620/is-it-possible-to-list-
all-functions-in-a-module) to list functions in a range of modules. But in my
interpreter I get as follows... |
How to read an untrusted certificate to extract informations using Python?
Question: I know it's possible to read a certificate in Python by using either OpenSSL
or M2Crypto, as greatly explained at [How can I retrieve the SSL certificate
information for a connection whether it's self-signed or not using
python?](http:... |
Python program returning error I cannot seem to fix
Question: I began this code by using a while loop to establish the menu (line 19-40) and
it worked perfectly before adding the functions and import at the top. Now it
keeps throwing back an indentation error at line 19 and none of my attempts
other than removing all t... |
Python - Convert time to different time zone with am/pm
Question: In Python, using this function (takes Eastern Standard Time (EST) with am/pm,
should output it in 3 time formats. Central Time (CT), Mountain Time(MT), and
Pacific Time(PT) all in the correct am/pm):
def time_in_24h(time,time_day): #time i... |
Python count substrings
Question: How do I find how many times does substring appears in string? I have
molecular formula and if the letters are uppercase it is one element(e.g.H),
if it has first Upper case letter and second lower case than it is one
element(e.g.Ba), and if there is number after element i have to add ... |
How to call a method from an already running python script
Question: I need to check if the python script is already running then calling a method
from the same running python script. But it must be on same process(pid), no
new process. Is this possible?
I tried some codes but not worked.
#!/usr/bin/env... |
Creating radio buttons from a list in python?
Question: The code below creates a check button for each item in the list:
cb_strings = ['item 1', 'item 2', 'item 3', 'item 4']
self.check_btns = []
for i in range(len(cb_strings)):
v = StringVar()
self.check_btns.append(Che... |
How to dump http request in python
Question: I am using http in my application.
request = urllib2.Request(url, postdata)
Is possible to get dump of this request on client side (after this line) ?
I need exactly what is sent to server (TCP dump ?), so
POST url HTTP/version\r\nHeader... |
Python urllib2 with headers not working
Question: I am trying to scrape a page for a certain url and I am using BeautifulSoup to
do so, with a request from urllib2. The problem I am having right now is that
it sends a different url to my python client than my browser. So I went around
and had a look at the header reque... |
Scrollbar not functioning properly Tkinter
Question: I am a newbie to Python.
I am trying to create a Scrollbar, which I did but the scrollbar is not
functioning properly.
The frame already shows all labels but what I expected was the frame will only
show up to 5 labels
and if frame contains more than 5 labels, then... |
Recording video with webcam using VideoCapture
Question: I want to record a video with python (using my webcam) and I came across
[VideoCapture](http://videocapture.sourceforge.net/) which was easy to install
on windows. I know there is OpenCV out there, but that was too much for me.
So far I can create every 0.04 sec... |
Iterate through and print the keys of a dictionary instead of its values?
Question: I have a series of extremely long URLs with keys in the format of
`myurls21,1`, `myurls21,2`, etc. that I am breaking up into component parts
using the following statement:
import concurrent.futures
import urllib.requ... |
How do I fix a "memory leak of type 'wxPyXmlSubclassFactory *', no destructor found" error from wxPython/wxFormBuilder?
Question: I'm trying to follow [this
tutorial](http://vcansimplify.wordpress.com/2013/04/08/ultra-quick-guis-with-
wxformbuilderpython/) to quickly make simple GUIs using wxPython and
wxFormBuilder.
... |
how do I sum up this python Dictionary and get the average?
Question: d =[{'C': 0, 'B': 2.0, 'A': 7.0, 'D': 3.0}, {'C': 2.0, 'B': 0, 'A': 5.0, 'D':
5.0}, {'C': 7.0, 'B': 5.0, 'A': 0, 'D': 10.0}, {'C': 3.0, 'B': 5.0, 'A': 10.0,
'D': 0}]
how do I sum up this python Dictionary and get the average ?...
Answer:
>>> ... |
using multiprocessing.Pool on bound methods
Question: I'm trying to use `multiprocessing.Pool` in my code but I got this exception:
`PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup
__builtin__.instancemethod failed`
I found [this](http://stackoverflow.com/questions/1816958/cant-pickle-type-
inst... |
Optimising Pandas multi-index lookup
Question: I Use Pandas 0.12.0. Say `multi_df` is a Pandas dataframe with multiple index.
And I have a (long) list of tuples (multiple indexes), named `look_up_list`. I
want to perform an operation if a tuple in `look_up_list` is in `multi_df`.
Below is my code. **Is there a faster ... |
Reading and Compressing a picture with RLE
Question: Currently I am learning python and I'd like to get a little bit more into Data
Compression. So I decided to try to code Run-Length Encoding(RLE).
From what I've read it can be useful when you try to compress pictures.
I would like to know what would be the easiest ... |
Python how to direct subprocess to output file
Question: I have created a script that receives a bunch of log files as input in order
to do some pattern matching. However, my "processFiles" method is not working
properly. It should write all data to "fileDest". But the created file remains
empty. If I put a "print proc... |
Python - Decode UTF-16 file with BOM
Question: I have a [UTF-16](https://en.wikipedia.org/wiki/UTF-16)
[LE](https://en.wikipedia.org/wiki/UTF-16#Byte_order_encoding_schemes) file
with [BOM](https://en.wikipedia.org/wiki/Byte_order_mark). I'd like to flip
this file in to UTF-8 without BOM so I can parse it using Python.... |
PermissionError when using python 3.3.4 and RotatingFileHandler
Question: I am trying to get a rotating log file for a GUI application I am writing with
python 3.3.4 and PyQt4.
I have the following snippet of code in my main script:
import logging
import resources
logger = logging.getLogger... |
SqlAlchemy not using utf8 charset even if specified
Question: I'm using Flask with Flask-SqlAlchemy with MySQL and my connection string does
have the `charset-utf8` parameter on my connection string.
I'm also using reflection and my Model is specified as this:
class Value(db.Model):
__bind_key__... |
Python exception handling: Check return value of function
Question: Before using the value of a return of a function, I want to check if the value
is useable. So what I have is more or less the following:
def get_module():
import foo
return foo
def do_something():
try:
... |
Error converting list to string
Question: I am trying to specify the position where I would like my data to be written
in my output file but I am getting the following error. Could I please be
advised on how I might resolve this issue?
Traceback (most recent call last):
File "C:/Python33/Upstream a... |
Do Dictionaries have a key length limit?
Question: I was wondering if Python had a limit on the length of a dictionary key.
For clarification, I'm not talking about the number of keys, but the length of
each individual key. I'm going to be building my dictionaries based on dynamic
values (after validation), but I'm no... |
Python: How Close (or exit) Python Process After QMainWindow Dialog is closed
Question: There are two .py files placed in a same folder:
dialog_01.py and dialog_02.py
Both files are copy of each other. Both build a simple QMainWindow dialog
window with two buttons: 'Ok' and 'Cancel'.
Clicking 'Ok'... |
Python, Mockito, Mocking Another Module's Imports
Question: Suppose I have module1.py
from my_library import useful_function
def do_something(x):
return useful_function(x)
I am testing module2.py
from module1 import do_something
def do_something_else(x):
... |
update a variable within a function?
Question: I'm teaching myself python 3.x and am struggling to resolve an issue I'm
having with variable scope.
In my program, I ask the user for an input, and then run a function to check
its value. If the value is correct, I continue. Otherwise, I wish to allow the
user to change ... |
scikit learn imputing values other than NaN
Question: I'm trying to impute values for different placeholders which represent empty
values in a matrix. For example, I want to impute a value whenever "?" is
present in a numpy 2darray.
To this end I create an `Imputer` like so:
from sklearn import preproce... |
How to use django template tag 'url' with django 1.6?
Question: I'm using Python 2.7.5, django 1.6.2 and bootstrap 3.
I know the template tag `{% url %}` changed since django 1.5. I've read the
[documentation for reverse
url](https://docs.djangoproject.com/en/1.6/topics/http/urls/#reverse-
resolution-of-urls) on djang... |
"from __future__ import unicode_literals" gives segfault in python 2.7
Question: all~
The segfault occured while i try to use rest_framework in a webapp as this:
from rest_framework import viewsets
finally, i pointed the problem occured here:
>>> from __future__ import unicode_... |
Execute a Python statement in a Bash script
Question: Is it possible to have Python evaluate a Python statement within a Bash shell
script? I am thinking about something along the lines of perl's `-e` option.
The problem at hand is that I'd like to use Python's `split` function on a
Bash string. I know it's doable in ... |
Memory issue in Python. Dictionary v.s. Database (or can you combine both?)
Question: I'm trying to find patterns of words for a huge input. I was using a
dictionary for this purpose, and after some hours the program crashed with
`MemoryError`.
I modified the program. I created a database via MySQLdb and I inserted th... |
Selenium - screenshot images taken by headless server are mangled
Question: I am using selenium webdriver (Python version) to take images of a web page
after it loads. When I go to a page and save an image using a python script on
my local computer, it looks fine. However, I am running the script on a server
and there ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.