text stringlengths 226 34.5k |
|---|
Encode in Python and decrypt in Javascript
Question: I've searched for this, there are lots of hits, but I can't find one that is
neither complete (pulls all the bits together) nor says its a bad idea, use
HTTP. I've tried lots of things based on the hits I've found, but I can't get
it to work.
The target problem is t... |
Python: Using mpi4py to bcast an array to other scripts with spawn
Question: I'm trying to write two scripts, one a master and one a worker, where the
master script will spawn multiple processes of the worker and then bcast a
numpy array to the worker spawns. From looking at the number of (vague)
tutorials online for m... |
Python dictionary having tuple keys and values
Question: What I like to have is a dictionary in the format of
`{(x1,y1):(a1,b1,c1),(x2,y2):(a2,b2,c2),(x3,y3):(a3,b3,c3),...}`
All the data is in a text file in a format like this:
x1 y1 a1
...
x1 y1 b1
...
x1 y1 c1
...
x2 y2 a2
... |
Getting Rethinkdb index metadata
Question: I'd like to obtain metadata about an index on a Rethinkdb table, such as
* what expression is used for arbitrary indexes
* what fields are used for compound indexes
* whether the index is multi or not
How can I get this information through the admin interface? Through ... |
How does os.path.join() work?
Question: Please help me understand how the builtin os.path.join() function works. For
example:
import os
print os.path.join('cat','dog') # 'cat/dog' no surprise here
print os.path.join('cat','dog').join('fish') # 'fcat/dogicat/dogscat/dogh'
On Mac (and i guess... |
Log-In Automation
Question: I am trying to write a Python script that will automate logging in to a web-
client. This is to automatically log-in to the web-client with a provided user
name and password. Below is my Python code:
import httplib
import urllib
import urllib2
header = {
... |
Can't set up a HTTP CGI Server in Python 2
Question: Does anyone notice this?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
class Handler(CGIHTTPRequestHandler):
cgi_directories = ... |
Excel (CSV) - transform header data to rows mapping with repeating rows
Question: I have Excel based data set which needs transformation. I would request a
Python based solution as I am learning Python and can read/modify the code
thereafter. I am OK with either an Excel or CSV based input/output.
**This is what my da... |
Python BeautifulSoup give multiple tags to findAll
Question: I'm looking for a way to use findAll to get two tags, in the order they appear
on the page.
Currently I have:
import requests
import BeautifulSoup
def get_soup(url):
request = requests.get(url)
page = request.text
... |
Debugging: Shuffle deck of cards in Python/ random
Question: I know the title sounds boring, because many people have already asked about
this topic. I hope it can help me get some insight into how the random module
works. The issue is, I wrote two different functions that I think should be
identical, but the results I... |
How does run.main() work?
Question: Please explain how following statement runs a Python script. There are no
custom function calls in this block:
if __name__ == '__main__':
import sys,os
import run
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
Let me paste th... |
py2app ValueError: total_size > low_offset (164 > 0)
Question: I have a simple python script with two resources that I want to covert to an
Mac OSX app. Script runs fins from the command line, but when i try to package
it into an app, I get:
Ante-scriptum: I'm building in /opt/k which has the right permisions...
... |
Best practice way for linking object attributes to class or object
Question: I am looking for a reliable and pythonic way of giving class attributes of a
certain type a back-reference to the class they are connected to.
i.e. if there is class definition like the one below, I want to give
`SomeAttribute()` a reference ... |
Camelot (Python framework): Specifying an Alternative EntityAdmin
Question: With the Camelot framework, models (subclassed from Entity) are defined with a
nested class (subclasses from EntityAdmin) that defines various gui properties
like layout and other widgets. The documentation indicates that multiple
EntityAdmins ... |
error to append integer in c++ boost python list
Question: I does this code and not work
#include <boost/python.hpp>
namespace bp = boost::python;
int main(int argc, char **argv) {
bp::list points;
int one = 1;
int two = 2;
int three = 3;
points.append(one)... |
Python Wave byte data
Question: I'm trying to read the data from a .wav file.
import wave
wr = wave.open("~/01 Road.wav", 'r')
# sample width is 2 bytes
# number of channels is 2
wave_data = wr.readframes(1)
print(wave_data)
This gives:
b'\x00\x00\x00\x00'
W... |
PyOpenGL-accelerate + numpy
Question: I'm installing
[MakeHuman](http://www.makehuman.org/doc/node/overview_of_os_specific_installations_and_build_procedures.html)
on Debian, so all dependencies was set up, but when launching it's an error:
SYS.PLATFORM: linux2
PLATFORM.MACHINE: x86_64
PLATFORM.P... |
How to install WTForms? Gettiing import error when trying to import forms
Question: I'm trying to follow the [Flask Mega
Tutorial](http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-
hello-world) for which I need to use WTForms. As is suggested in the tutorial,
I use a virtualenv in which I installed WT... |
Optimizing access on numpy arrays for numba
Question: I recently stumbled upon [numba](http://numba.pydata.org/) and thought about
replacing some homemade C extensions with more elegant autojitted python code.
Unfortunately I wasn't happy, when I tried a first, quick benchmark. It seems
like numba is not doing much bet... |
Peewee ORM gives IntegrityError: user_id may not be NULL
Question: I'm trying to use the Peewee ORM for my new (Flask) website, and now I ran
into a problem. I just created a simple model like so:
from peewee import TextField, DateTimeField, IntegerField, ForeignKeyField
from app import db
R... |
how can I subtract a method value from another method value in python?
Question: I've being trying to subtract a method value from another method value but it
gives me a an error even when I use variables.
from tkinter import *
statistics = Tk()
screenwidth = statistics.winfo_screenwidth
wind... |
Merge CSV Files in Python with Different file names
Question: I'm really new to Python, so this question might be a bit basic. I have 44 csv
files with the same headers and different file names. I want to combine them
all into one file.
Each file is named "Votes-[member-name]-(2010-2014)-[download-time].csv"
The head... |
Making CSV files easier to modify/navigate within Python using headers / column names?
Question: SO,
I have a CSV file with a varying number of columns which _I think_ means that
the traditional means of making headers as I have **attempted** below won't
work...
The reason I want some headers is because it gets incre... |
Paginator in python django crashes on dict
Question: I have 2 types of gathered data from database:
One is `[<NaseljenoMesto: NaseljenoMesto object>, <NaseljenoMesto:
NaseljenoMesto object>]`
And another is: `[{'naseljenomesto_drzava__naziv': u'Srbija', 'sifraMesta':
u'ZR', 'nazivMesta': u'Zrenjanin', 'id': 3}, {'nas... |
Calling IDA Pro through python
Question: I am trying to use a python script to call IDA Pro and have it run in bash
mode. Similar to that of the linux terminal line './idal -B input-File' is
there a quick and simple way I can do this throughout the python script? I
have looked through the IDA Pro book and I can only fi... |
Creating an sqlite database search engine with python
Question: I have an sqlite database with 2 tables. I need to create a cgi search engine
for the database, with 2 options in a drop-down menu: Name & Keyword.
If the option is Keyword, the 1st table is searched for a matching keyword (in
any column). If the option i... |
Python 2.7: Issues When Importing a Class
Question: I have been searching high and low for an answer and cannot seem to find one.
I am running into a fundamental issue when attempting to import a class from
another file. I am relatively new to Python and OOP in general, so forgive me
if my query is rudimentary.
**The ... |
Python pandas find starting/ending row and rounding numbers
Question:
import pandas as pd
import numpy as np
import urllib
url = 'http://cawcr.gov.au/staff/mwheeler/maproom/RMM/RMM1RMM2.74toRealtime.txt'
urllib.urlretrieve(url,'datafile.txt')
df = pd.read_table('datafile.txt', sep='\s... |
python - recursively deleting dict keys?
Question: I'm using Python 2.7 with `plistlib` to import a .plist in a nested dict/array
form, then look for a particular key and delete it wherever I see it.
When it comes to the actual files we're working with in the office, I already
know where to find the values -- but I wr... |
Compare incomplete date list with a reference date list
Question: I know this is possible. I know there is a simple solution, but everything
I've tried has failed.
Here's the deal:
I have a dataset in Excel format containing 939,019 weather station records
(rows). The date/time interval is every 10 minutes starting f... |
Summing one array in terms of another - python
Question: I have two corresponding 2D arrays, one of velocity, one of intensity. The
values of intensity match each of the velocity elements.
I have created another 1d array that that goes from min to max velocity in
even bin widths.
How would I sum the intensity values ... |
How to skip the unmodified modules importing in PYTHON
Question: I have a lot of modules to import before running each script. But the modules
i am importing is same in all the scripts. In case of debugging i have to
change some code in one or more modules and again run the script. So each time
python imports all the m... |
Python debugging, stop at particular output
Question: I have complex python project with lots of modules, loggers, twisted defereds
and other stuff.
And somewhere in the code some line is printed to logs, and I want to find out
where. Usually I just search the codebase for that string, but now that string
is generated... |
Looking for a quick way to speed up my code
Question: I am looking for a way to speed up my code. I managed to speed up most parts
of my code, reducing runtime to about 10 hours, but it's still not fast enough
and since I'm running out of time I'm looking for a quick way to optimize my
code.
**An example:**
... |
Simple loading time series and plot in python
Question: Being a beginner with python, I am very frustrated because after hours of
research I can not find a solution for reading+plotting time serieses in
python which could be done in matlab, R or gnuplot in 1 minute.
Data file:
# id date ... |
Java Run Static Method in New Thread
Question: I just started learning java and I ran into a slight road block involving
threads. I have a static method that I would like to run in its own thread, is
this possible? In python I know it would look something like this: `import
thread;thread.start_new_thread( my_function, ... |
Is there a method like append for dictionaries
Question: How do i add key,value to a dictionary in python? I defined an empty
dictionary and now I want to pass a bunch of keys from a list and set their
value as 1. From what I did it creates me every iteration a new dictionary,
but I want to append the key,value so even... |
Python solution for reading a text file into an if statement
Question: I am a new to Python and I am trying to parse some network data to figure out
where a certain ip address is based on the city that it is in. I have the
following code working below. But I have several hundred lines of information
that I would like m... |
Python: arguments - 4 arguments allowed, 5 given
Question: Trying to create a matrix to start a search algorithm.
from numpy import *
z11 = vars()
z12 = vars()
z13 = vars()
z14 = vars()
z21 = vars()
z22 = vars()
z23 = vars()
z24 = vars()
z31 = vars()
z32 = var... |
NLTK set method prints characters, not words
Question: I'm new to NLTK (and python...) and I'm having two issues with one of its
basic methods: when I call
sorted(set(<one of nltk's preloaded corpora>))
it prints a list of all the words in the text, but each word is preceded by
'u', like so: [u'you... |
Python numba.jit types
Question: I have been trying to deduce how the types are set from the numba
documentation all day. I have gotten a bit of the way, but now I want to make
a function which returns a one-dimensional array, and a two-dimensjonal array,
and take a bunch of args, and I struggle to get any further:
... |
urllib.request for python 3.3 not working to download file
Question: I would like to download a large archive file with python and save it, but
urllib is not working for me. This is my code:
import urllib
urllib.request("http://www.petercollingridge.co.uk/sites/files/peter/particle_tutorial_7... |
Find + Find next in Python
Question: Let L be a list of strings.
Here is the code I use for finding a string `texttofind` in the list L.
texttofind = 'Bonjour'
for s in L:
if texttofind in s:
print 'Found!'
print s
break
How would you do a **Find nex... |
How to use Hg-to-Git tool - fast-export?
Question: I have tried the instructions from this [SO
post](http://stackoverflow.com/questions/16037787/convert-mercurial-project-
to-git):
cd ~
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/fast-export/hg-fast-export.s... |
Python script to collect all hostnames of ip addresses with only prime entities
Question: I have a Python script to collect hostnames of ip address with primes as byte
entities. E.g., 211.13.17.2 is a valid ip according to my problem set where
every byte entity(decimal representation) is a prime.
**Code:**
... |
How to re-implement Ui_MainWindow generated by Qt
Question: I've created a interface in Qt as .ui file and then converted it to a python
file. Then, I wanted to add some functionality to the components such as radio
button, etc. For doing so, I tried to re-implement the class from Qt and add
my events. But it gives the... |
Can Python read from a Windows Powershell namedpipe?
Question: I have the following named pipe created in Windows Powershell.
# .NET 3.5 is required to use the System.IO.Pipes namespace
[reflection.Assembly]::LoadWithPartialName("system.core") | Out-Null
$pipeName = "pipename"
$pipeDir = [Sys... |
Logging into Stack Overflow with Mechanize and Python
Question: I have been using this guide to help me:
<http://www.pythonforbeginners.com/cheatsheet/python-mechanize-cheat-sheet/>
I want to log into Stack Overflow and print out my login response using
Mechanize in Python. I have been troubleshooting to find a form n... |
Python - Importing strings into a list, into another list :)
Question: Basically I want to read strings from a text file, put them in lists three by
three, and then put all those three by three lists into another list. Actually
let me explain it better :)
Text file (just an example, I can structure it however I want):... |
Does the interpreter compile python scripts?
Question: I wrote a script, say, `samplescript.py`. All I can recall doing with, other
than editing it, is running it through the command-line python interpreter.
Later, I found a `samplescript.pyc` file. Does running a script through the
interpreter always invoke the compi... |
Python mock.patch doesn't patch the correct import
Question: # Code
def test_get_network_info(self):
with open(dirname(abspath(__file__)) + '/files/fake_network_info.txt', 'r') as mock_network_info:
with patch('subprocess.check_output', Mock(return_value=mock_network_info.read())):
... |
How to use socket with a Python client and a C++ server
Question: I have a simple client/server program.
The client is written in python as this :
import socket
import sys
HOST, PORT = "localhost", 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST... |
Project/Multiple Class Verbose Mode Python
Question: I'm wondering what the simplest way to enable debugging/verbose mode outputs
in a project that involves multiple classes/files. The answer given here:
[Easier way to enable verbose
logging](http://stackoverflow.com/questions/14097061/easier-way-to-enable-
verbose-log... |
Python modules run function from file
Question: I have a python (2) project with this structure:
alerter
│ README.txt
│ __init__.py
│ __init__.pyc
│
└───lib
Alarm.py
Alarm.pyc
__init__.py
__init__.pyc
in `lib.__init__.py` I h... |
Generate output files from template file and csv data in python
Question: I need to generate xml files poulated with data from a csv file in python
I have two input files:
one CSV file named data.csv containing data like this:
ID YEAR PASS LOGIN HEX_LOGIN
14Z 2013 (3e?k<.P@H}l hex091... |
python opencv error finding contours
Question:  I'm trying to find the contour of the
attached image of a tshirt. FindContours returns a rectangular frame around
the tshirt, and doesn't find any additional contours. My goal is to find the
external contour of the tshirt. Any idea w... |
cx_freeze & bundling files
Question: At present I am using pyinstaller for bundling my python application. I am
equally migrating to pyGObject (due to pygtk being depreciated).
Now pyinstaller does not support pyGObject and I have as of yet not figured
out the required hooks... One of the other downsides of pyinstalle... |
Grid search function in Python
Question: I am trying to write a parameter search function to loop over one of the
parameters and repeatedly call a function with all other parameters the same,
other than the one I am searching over. Here is some sample code:
def worker1(a, b, c):
return a + b + c
... |
Can a spawned process communicate with the "main" MPI communicator
Question: Is there a way using MPI to let spawned processes communicate with all other
actors in the MPI_WORLD and not only with the parent that spawned the process?
Now I have two main agents, the so-called master and slave that run the
following code... |
Replacing a leading text string with the same string in python
Question: I have the following tags in a xml file as
> &\hbox{(1b)}}$$ with the initial condition <2inline-formula>$x(0)$, where
> the subscript <3inline-formula>$p$ means 'plant'; <4inline-formula>$x_{p}(t)
> \in \Re^{n}$ is the state, <5inline-formula>$y... |
python Weather API location id
Question:
a=pywapi.get_loc_id_from_weather_com("pune")
{0: (u'TTXX0257', u'Pune, OE, Timor-leste'),
1: (u'INXX0102', u'Pune, MH, India'),
2: (u'BRPA0444', u'Pune, PA, Brazil'),
3: (u'FRBR2203', u'Punel, 29, France'),
4: (u'IDVV9705', u'Punen, JT, ... |
Python permutations
Question: I am trying to generate pandigital numbers using the itertools.permutations
function, but whenever I do it generates them as a list of separate digits,
which is not what I want.
For example:
for x in itertools.permutations("1234"):
print(x)
will produce:
... |
How to get a percentile for an empirical data distribution and get it's x-coordinate?
Question: I have some discrete data values, that taken together form some sort of
distribution. This is one of them, but they are different with the peak being
in all possible locations, from 0 to end. /1024/1024)
which hopefully would give me the size of the list in RAM in Mb.
it o... |
Adding elements to an JSON object in a external JSON file?
Question: * * *
(After months of surfing the internet, talking to the school's computing
department and try code out, I still don't get how to do it, but I do know
more specific about what I trying to do)
* * *
Previously I said I want to "Add lines" to a ex... |
How to import liblas module in Python?
Question: I am using liblas for python to read .las file. When I enter:
from liblas import file
It gives me:
> No module named liblas.
I already set up las library path in system, `lasinfo` is working fine. Can
anyone tell me how to import las library in Pyt... |
iPython: 'no module named' ImportError
Question: Windows: I have the Python package CVXOPT installed on my computer for the
regular Python distribution, though not specifically with Anaconda, so it
imports fine when I'm doing text editor/cmd python scripting. I tried
installing CVXOPT with Anaconda, but that didn't wor... |
Python regex on wikitext template
Question: I'm trying to remove line breaks with Python from wikitext templates of the
form:
{{cite web
|title=Testing
|url=Testing
|editor=Testing
}}
The following should be obtained with re.sub:
{{cite web|title=Testing|url=Testing|e... |
using html5lib with xml.etree.ElementTree
Question: I need is a way to use the html5lib parser to generate a real
xml.etree.ElementTree. (lxml is not an option for portability reasons.)
`ELementTree.parse` [can take a
parser](http://docs.python.org/2/library/xml.etree.elementtree.html#xml.etree.ElementTree.parse)
as a... |
Python - directed edge list to dictionary of dictionaries
Question: I have a list of directed edges in a file in the form
Source_Id Target_Id Edge_Type
A B Train
A C Bus
B D Bus
C A Train
... ..... |
Getting URLError Exception when caching webdriver instances
Question: I am attempting to cache webdriver instances across test case classes. I do
not need a "clean" webdriver since I am simply using PhantomJS to query the
DOM (I do need JavaScript enabled, which is why I am not simply fetching the
source and parsing th... |
python - specifically handle file exists exception
Question: I have come across examples in this forum where a specific error around files
and directories is handled by testing the `errno` value in `OSError` (or
`IOError` these days ?). For example, some discussion here - [Python's
"open()" throws different errors for ... |
Parse output of 'ip addr' via Python
Question: I need some help parsing the output of the `ip addr` command as dumped to a
text file, with contents like this:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN \ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
1: lo inet 1... |
Open a read-only Excel file using Python
Question: I have a program (zTree) that is writing an Excel file and updating it
constantly. What I need this Python program to do is read in the data from the
Excel file as its updating. The problem that I'm having though is that when I
try to read in the data using xlrd, I get... |
Python Updating RRDTool with Serial Port Data
Question: I am trying to update a RRDTool DB with serial information. Is it possible to
declare the serial data as a variable in the update line? Using the code
below, rrdtool doesn't see the N: timestamp. However if I manually enter the
data following the "N:" it will upda... |
Mod_wsgi fails to load django.core.handlers.wsgi
Question: Ok, after 5-6 hours of trying, I give up. I have searched the web, tried all
solutions suggested, but nothing is solving my problem.
**Goal:** Set up Django on my Ubuntu 12.04 VPS.
**Problem:** `Exception occurred processing WSGI script [...] ImportError: No
... |
How to print a reStructuredText node tree?
Question: Section [Parsing the
Document](http://docutils.sourceforge.net/docs/dev/hacking.html#parsing-the-
document) of The [Docutils Hacker's
Guide](http://docutils.sourceforge.net/docs/dev/hacking.html) mentions the
`quicktest.py` utility that can be used to print a node tr... |
python ctype intialising a structure
Question: My structure contains all unsigned char elements
typedef struct
{
unsigned char bE;
unsigned char cH;
unsigned char cL;
unsigned char EId1;
unsigned char EId0;
unsigned char SId1;
unsigned char SId0... |
Python Server Socket Without Infinite Loop?
Question: I'd like to create a class that allows sending and receiving on the same port
and create an event-driven application from incoming messages while the
program does it operations. I don't have much experience with sockets so I
don't know how to do this. Here is my Sim... |
How to concatenate and convert hex to base 64 in Python?
Question: I'm trying to convert hex values into base 64.
I have a script that does some calculations to each value.
I then want to convert the final values to base 64.
import base64
for i, v in enumerate([0x31, 0x37, 0x32, 0x2e]):
z=... |
OpenCV Python unsupported array type error
Question: I am new to Python (but not new to openCV) and I am pretty sure everything is
installed correctly, I have tested some programs and the seem to work fine,
but when ever I want to draw on an image, for example this code taken from a
Python openCV tutorial :
... |
ctypes: Correctly sublcass c_void_p for passing and returning custom data types, by example
Question: I am working with `ctypes` and cannot seem to figure out how to work with
custom data types. The hope is to have a Python interface to the public
methods of a C++ `cell` class and a C++ `cellComplex` class.
My current... |
How to properly parse parent/child XML with Python
Question: I have a XML parsing issue that I have been working on for the last few days
and I just can't figure it out. I've used both the ElementTree built-in to
Python as well as the LXML libraries but get the same results. I would like to
continue using ElementTree i... |
Executing a shell script in Python from the JSON document
Question: I am trying to execute the shell script in Python using subprocess module.
Below is my shell script which is called as `testing.sh`.
#!/bin/bash
hello=$jj1
echo $hello
echo $jj1
echo $jj2
for el1 ... |
Calling variables from inside functions in Python
Question: I know I have already asked a question like this before but I have made my
code much cleaner and I am still coming up with a problem.
My code goes like this:
class Email_Stuff:
def Get_From_Email():
#code to open... |
I want to download code from Google App Engine
Question: I want to update the app in google app store. But I can't download the code...
Is there any way to update the app without downloading the code?
I tried to download with python, google app engine SDK...
But appcfg.py download_app -A
This command does not work ... |
Placing the legend outside the plot
Question: I want to position the legend outside the drawing box. I do not find a clean
way to do this. The main problem is having everything fit on the file saved.
The only thing I have been able to figure out is this code:
#! /usr/bin/python
import matplotlib
... |
Best and/or fastest way to create lists in python
Question: In python, as far as I know, there are at least 3 to 4 ways to create and
initialize lists of a given size:
**Simple loop with`append`:**
my_list = []
for i in range(50):
my_list.append(0)
**Simple loop with`+=`:**
... |
Python memory management for variables
Question: I have a question regarding python memory management. I have the following
code
def operation(data):
#some manipulations on data
result=something.do(data)
#some manipulations on result
return result
Now I am calling th... |
Relationship between (1) hash function, (2) length of signature and (3) jaccard similarity?
Question: I am trying to understand/implement minHash based jaccard similarity in
python. The main goal is use it in MapReduce. However I am not clear how the
choice of hash function and length of signature affects error rate in... |
why is the python GUI interface fleeting
Question:
#coding=utf-8
import wx
class App(wx.App):
def OnInit(self):
frame=wx.Frame(parent=None,title='Bare')
frame.Show()
return Ture
app=App()
app.MainLoop()
runs OK! but the GUI interface is fleeting, j... |
Numbers without remainder python
Question: I need to print out numbers between 1 and n(n is entered with keyboard) that
do not divide by 2, 3 and 5. I need to use while or for loops and the
remainder is gotten with %. I'm new here and I just don't understand the usage
of %? I tried something like this:
i... |
global name 'GLib2Reactor' is not defined
Question: I'm struggling to get some python code using the python-brisa framework to
work, the code is not written by me but should be straight forward.
from brisa.core.reactors import install_default_reactor
reactor = install_default_reactor()
f... |
Python: correct way to pass objects between modules
Question: I am following the [Flask SQLalchemy
Quickstart](http://pythonhosted.org/Flask-SQLAlchemy/quickstart.html) which
has all of the code in a single file:
Here is my initial **index.py** :
from flask import Flask
from flask.ext.sqlalchemy imp... |
Is there a way to have a python program run an action when it's about to crash?
Question: I have a python script with a loop that crashes every so often with various
exceptions, and needs to be restarted. Is there a way to run an action when
this happens, so that I can be notified?
Answer: You could install an except... |
Tkinter with Python 3.3 : Change colour of button on click
Question: So I have been playing with tkinter to try add a gui to a lift simulator
project I have written for university. It is not really needed, but I would
like to add it.
Here is the code that I currently have.
import tkinter as tk
... |
Python PXSSH GUI spawn on login failure
Question: I can't stop the GUI from spawning when a login failure occurs.
simple example that fails and spawns a GUI.
>>> import pxssh
>>>
>>> ssh = pxssh.pxssh()
>>> ssh.force_password = True
>>> ssh.login('127.0.0.1', 'root', 'falsePW')
Tra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.