text stringlengths 226 34.5k |
|---|
Call a functor in Python
Question: Should be easy, but somehow I don't get it. I want to apply a given function.
Background is copy a class and applying a given method on the newly created
copy.
**Major Edit. Sorry for that.**
import copy
class A:
def foo(self,funcName):
... |
Importing scrapy.conf.settings generates error
Question: Using scrapy version 0.16. Trying to create a standalone spider runnable from
a script as per [this gist](https://gist.github.com/484009). Importing the
above generates this:
Traceback (most recent call last):
File "./spiderctl.py", line ... |
How do I make a regular expression that matches the following in Python?
Question: Assuming I have many strings that are like this:
<a id="1.1">
<a id="1.1.1">
<a id="1.1.2">
<a id="1.1.3">
<a id="1.2">
<a id="1.2.1">
I want to make a regular expression that catches only the one... |
os.waitpid doesn't return a tuple containing pid, and its exit status
Question: I try to come up with a workaround for this [python
bug](http://bugs.python.org/issue3905) calling `subprocess`. I figured the way
to go is using `os.system` in combination with `os.waitpid`. To test this I
wrote the code below. `system_cal... |
Using multiprocessing.Manager.list instead of a real list makes the calculation take ages
Question: I wanted to try different ways of using `multiprocessing` starting with this
example:
$ cat multi_bad.py
import multiprocessing as mp
from time import sleep
from random import randint
... |
Python rock paper scissors score counter
Question: I am working on a rock paper scissors game. Everything seems to be working
well except the win/loss/tie counter. I have looked at some of the other games
people have posted on here and I still cannot get mine to work. I feel like I
am soooooo close but I just can't get... |
A fast way to extract all ANCHORs from HTML in python
Question: Is there any simple, robust and fast way to extract all anchors' href
attributes HTML in python?
I know there is a solution using BeautifulSoup, but the problem with
BeautifulSoup is that it's too heavy, and consumes a lot of memory on some
URLs.
The tas... |
How can I run Instruments from Python?
Question: Anyone know how to run Instruments from Python? I tired to use os.system and
it didn't work.
If I run Instruments from a command line, I only need to run:
instruments -w id -t xxxxxxxxxxxxxx xx.js
I will need to run the above in python. I suppose th... |
Logging variable data with new format string
Question: I use logging facility for python 2.7.3. [Documentation for this Python
version say](http://docs.python.org/2/howto/logging.html):
> the logging package pre-dates newer formatting options such as str.format()
> and string.Template. These newer formatting options a... |
Python: How I can define in sphinx which .rst files and directories should be used?
Question: **How I can define in sphinx which .rst files and directories should be
used?**
I want to include an automatic documentation generator in my
testing/building/documentation script. _sphinx-quickstart_ was executed in my
worksp... |
Python - How do you detect that a module has been loaded by custom loader?
Question: Before Python-3.3, I detected that a module was loaded by a custom loader with
`hasattr(mod, '__loader__')`. After Python-3.3, all modules have the
`__loader__` attribute regardless of being loaded by a custom loader.
Python-2.7, 3.2:... |
Haven't started thread but Python throws exception 'Thread already start'
Question: I am writing a producer-consumer application. The producer threads start fine
but when I try to start the consumer threads, I get an exception. Here's the
relevant code:
#Producer threads
for i in range(nThreads):... |
benchmarks: does python have a faster way of walking a network folder?
Question: I need to walk through a folder with approximately ten thousand files. My old
vbscript is very slow in handling this. Since I've started using Ruby and
Python since then, I made a benchmark between the three scripting languages to
see whic... |
Django advanced query
Question: I'm using Django ORM to handle my database queries. I have the following db
tables:
* resource
* resource_pool
* resource_pool_elem
* reservation
and the following models:
class Resource(models.Model):
name = models.CharField(max_length=200)
... |
Categorize different images
Question: I have a number of images from Chinese genealogies, and I would like to be
able to programatically categorize them. Generally speaking, one type of image
has primarily line-by-line text, while the other type may be in a grid or
chart format.
Example photos
* 'Desired' type: <ht... |
Lazy transform in C++
Question: I have the following Python snippet that I would like to reproduce using C++:
from itertools import count, imap
source = count(1)
pipe1 = imap(lambda x: 2 * x, source)
pipe2 = imap(lambda x: x + 1, pipe1)
sink = imap(lambda x: 3 * x, pipe2)
for i i... |
How do I fairly assign tasks to workers in Python? - Splitting iterable into similarly sized chunks
Question: I have workers and tasks to do:
workers = ['peter', 'paul', 'mary']
tasks = range(13)
Now I want to split the tasks into chunks or batches of work, so that each
worker can work on one b... |
python - argparse one argument instead of several others
Question: For example I have options:
parser.add_argument('-b', action="store_true")
parser.add_argument('-c', action="store_true")
parser.add_argument('-d', action="store_true")
I want to enable all of them with synonym option "-a". ... |
Index out of range error Python greedy method
Question: Hello I am currently getting an index out of range error from the following
code: (I will post the code first and then the error)
# Main File:
import Knapsack_Test
size = 10
W = 2*size
knapsack = Knapsack_Test.Knapsack_Test()
... |
Random sampling from a set of integers
Question: I am working with python 3.2 and I spent a lot of time trouble shooting this,
and I still can't seem to wrap my brain around it.
`number = random.randint ( x0 ,xn )`
I'm generating a random number. It's purpose is to make my code come at me
differently everytime.
For ... |
reorder byte order in hex string (python)
Question: I want to build a small formatter in python giving me back the numeric values
embedded in lines of hex strings.
It is a central part of my formatter and should be reasonable fast to format
more than 100 lines/sec (each line about ~100 chars).
The code below should g... |
Paramiko hanging during authentication, when runned by dint of unittest runner
Question: Good day.
I have a strange problem with `paramiko` ssh client. `Connect paramiko` method
hangs when it's called outside `unittest2` classes/functions and code was run
by unittest runner.
There is a piece of code, where problem ap... |
Copying value of cell (X,Y) to cell (A,B) in same sheet of an Excel file using Python
Question: I am using the modules `xlwd`, `xlwt` and `xlutil` to do some Excel
manipulations in Python. I am not able to figure out how to copy the value of
cell `(X,Y)` to cell `(A,B)` in the same sheet of an Excel file in Python.
Cou... |
My Google App Engine appspot URL wont work
Question: I recently created my Google App Engine account, and uploaded my application,
and have an instance of said app running.
I can access my app via localhost:8080 but when I try to use
myappid.appspot.com I get a 500 Server Error (Of course I replace "myappid"
with my a... |
Different encoding in Jython's Java and Python level
Question: I'm using Sikuli (see sikuli.org) which uses jython2.5.2.
Here is a summary of the class Region on the Java level:
public class Region {
// < other class methods >
public int type(String text) {
System.o... |
Setting up default pylint config.rc file in Windows
Question: I'm using Pylint under Windows, and it's not reading my pylint-config.rc file.
Is there a way to set up a default .rc file for Python within windows so that
I don't have to keep typing it into the command line? Thanks.
Answer: I don't have a windows box at... |
Why am I getting an IndexError for a (seemingly) properly-split string?
Question: I currently have a script that is supposed to fetch and return the number of
clicks a Bit.ly link has. I start out by gathering and reading the data from a
Bitly url, which I appear to be doing correctly.
bitly_data = "... |
python multiprocessing.Process.Manager not producing consistent results?
Question: I've written the following code to illustrate the problem I'm seeing. I'm
trying to use a Process.Manager.list() to keep track of a list and increment
random indices of that list.
Each time there are 100 processes spawned, and each proc... |
Django GeoIP import
Question: > **Possible Duplicate:**
> [Error setting up geoip on
> Django](http://stackoverflow.com/questions/4896996/error-setting-up-geoip-
> on-django)
I get the "cannot import name GeoIP" error from the browser but not on python
terminal. for example for geodata in /tmp/geo. the following wo... |
strange memory leak with python + paramiko
Question: I have an (apparent) memory leak in a python script that I can't quite explain
(the resident memory just keeps growing). It started off with about 6MB
resident, I left it running overnight and it had gotten to over 200MB (I did
that to rule out a sawtooth memory usag... |
Call Python function from Javascript code
Question: I'd like to call a `Python` function from `Javascript` code, because there
isn't an alternative in `Javascript` for doing what I want. Is this possible?
Could you adjust the below snippet to work?
Javascript part:
var tag = document.getElementsByTagNam... |
Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed error while using multithreading module
Question:
def execute_on_host((hostname, command), username=config['username'], keyfile=config['keyfile']):
print hostname
ssh_client = paramiko.SSHClient()
ssh_cl... |
Comparing speed of non-matching regexp
Question: The following Python code is incredibly slow:
import re
re.match( '([a]+)+c', 'a' * 30 + 'b' )
and it gets worse if you replace 30 with a larger constant.
I suspect that the parsing ambiguity due to the consecutive `+` is the
culprit, but I'm no... |
PyPy displaying inaccurate benchmark results?
Question: I was working on [Project Euler](http://projecteuler.net/problem=204) and
wondered if I could speed up my solution using PyPy. However, I found results
quite disappointing, as it took more time to compute.
d:\projeuler>pypy problem204.py
3462.08... |
Plot really big file in python (5GB) with x axis offset
Question: I am trying to plot a very big file (~5 GB) using python and matplotlib. I am
able to load the whole file in memory (the total available in the machine is
16 GB) but when I plot it using simple imshow I get a segmentation fault. This
is most probable to ... |
How to append functions to current module from unrelated script in Python
Question: I have two python scripts in different locations. I try to import the
functions of the second one in such a way that they are integrated with the
globals of the first one. That works fine. However when I call functions in
the first scri... |
use beautiful soup to parse a href from given html structure
Question: I have the following given html structure
<li class="g">
<div class="vsc">
<div class="alpha"></div>
<div class="beta"></div>
<h3 class="r">
<a href="http://www.stackoverflow.com"></a>
</h3>
... |
Sleep Program Until Keypress
Question: I have the following code
#!/usr/bin/python
import keybinder
def Mark(args):
print "Why, hello!"
keybinder.bind("<Super>m", Mark, "junk")
KEYBINDER.MAIN_LOOP_KEYPRESS()
In other words, I would like to make a program which slee... |
UDP Server frame gap
Question: I'm new to python and trying to get some help here. I've written a code to
transmit UDP data through the socket. I wanted to re-transmit the data in a
loop every 50 microsecond but I can only send it every 3 seconds! I'm sure I'm
doing something wrong , can you help me out ? I've pasted t... |
How to install python-levenshtein on Windows?
Question: After searching for days I'm about ready to give up finding precompiled
binaries for Python 2.7 (Windows 64-bit) of the [Python Levenshtein
library](http://pypi.python.org/pypi/python-Levenshtein/), so not I'm
attempting to compile it myself. I've installed the mo... |
Can't install JPype on Ubuntu 12.04
Question: I've consulted this: [Cannot install JPype on ubuntu 12.04 64
bit](http://stackoverflow.com/questions/11949160/cannot-install-jpype-on-
ubuntu-12-04-64-bit)
And I'm following the tutorial here:
<https://github.com/johanlundberg/neo4j-django-tutorial>
It seems I'm still ha... |
compiled pig move output to input
Question: I'm trying to run a an embedded Pig script (embeded in Python) where I need to
take the output/result of the script and feed it back into script as the
input. I'm sure there is an easy way to do this but all the examples seem
overly simplistic and are using one column example... |
How to include python files of Java project into .war with maven?
Question: I have Java project made with maven. So I have typical maven project layout.
And I use Jython. So I got few python files. Wich I use through
PythonInterpreter in Java classes.
I place my python files in src/main/py folder. And I use this path... |
basic function not working -> 'name 'happyBirthdayEmily' is not defined'
Question: I'm following [this guide](http://anh.cs.luc.edu/python/hands-
on/3.1/handsonHtml/functions.html) and I can't get a basic function to work.
`birthday2.py`
def happyBirthdayEmily(): #program does nothing as written
... |
How to reconfigure tkinter canvas items?
Question: I don't know if this question has duplicates , but i haven't found one yet.
when using python you can create GUI fastly , but sometimes you cannot find a
method to do what you want. for example i have the following problem:
let's suppose that there is a canvas called... |
Ideas or algorithms when programming an NAT
Question: I'm working on a Python tunneling project using TUNTAP. The data received on a
TUNTAP interface contains the original IP packet including all headers. I can
do one of two things.
On the incoming side I am listening with Twisted. On the outgoing side I will
have a r... |
How do I make Python, QT, and Webkit work on a headless server?
Question: I have Debian Linux server that I use for a variety of things. I want it to be
able to do some web-scraping jobs I need done regularly.
This code can be [found here](http://bit.ly/QeqvzX).
import sys
from PyQt4.QtGui import ... |
Turning a string into a list with specifications
Question: I want to create a list out of my string in python that would show me how many
times a letter is shown in a row inside the string. for example:
my_string= "google"
i want to create a list that looks like this:
[['g', 1], ['o'... |
Python lxml.html XPath "attribute not equal" operator not working as expected
Question: I'm trying to run the following script:
#!python
from urllib import urlopen #urllib.request for python3
from lxml import html
url = 'http://mpk.lodz.pl/rozklady/1_11_D2D3/00d2/00d2t001.htm?r=KO... |
Setting a property doesn't work - dumb syntax error?
Question: I'm probably making some elementary mistake...
When I initialize and look at a property of an object, fine. But if I try to
set it, the object doesn't update itself. I'm trying to define a property
which I can set and get. To make it interesting, this rect... |
python split a pandas data frame by week or month and group the data based on these sp
Question:
DateOccurred CostCentre TimeDifference
03/09/2012 2073 28138
03/09/2012 6078 34844
03/09/2012 8273 31215
03/09/2012 8367 28160
03/09/2012 8959 32037
03/09/2012 9292 3... |
django-hstore on Heroku
Question: I've got a Django (v 1.3.3) project deployed on Heroku (cedar stack). It uses
the recommended dj_database_url for configuring settings.DATABASES. Everything
works great (to this point).
However, I want to start using [django-
hstore](https://github.com/jordanm/django-hstore) for part ... |
Boto script to download latest file from s3 bucket
Question: I like to write a boto python script to download the recent most file from the
s3 bucket i.e. for eg I have 100 files in a s3 bucket I need to download the
recent most uploaded file in it.
Is there a way to download the recent most modified file from S3 usin... |
PDF bleed detection
Question: I'm currently writing a little tool (Python + pyPdf) to test PDFs for printer
conformity.
Alas I already get confused at the first task: Detecting if the PDF has at
least 3mm 'bleed' (border around the pages where nothing is printed). I
already got that I can't detect the bleed for the co... |
How to parse single file using Python bindings to Clang?
Question: I am writing a simple tool to help with refactoring the source code of our
application. I would like to parse C++ code based on wxWidgets library, which
defines GUI and produce XML `.ui` file to use with Qt. I need to get all
function calls and value of... |
in python error while importing GeoIP on CentOs server
Question: I am using Django, and when I am using the geoip package or importing GeoIP I
am getting the following error on centos, while it is working well on ubuntu
12.04.
The error is as follows
from django.contrib.gis.utils.geoip import GeoIP
... |
concurrent connections in tornado
Question: I have a server running on tornado. I have a page that opens a `websocket` to
the same server. Now I have observed that opening multiple instances of this
page makes all of them wait except one. Only after that one has finished its
websocket, does another one start. Is this n... |
python/beautifulsoup to find all <a href> with specific anchor text
Question: I am trying to use beautiful soup to parse html and find all href with a
specific anchor tag
<a href="http://example.com">TEXT</a>
<a href="http://example.com/link">TEXT</a>
<a href="http://example.com/page">TEXT</a>
... |
Why does this work via the command line, but not via a web browser?
Question: Why does this work via the command line, but not my via a web browser? (both
files in python only the 2nd one loads)
import cgi
import cgitb; cgitb.enable()
import BaseHTTPServer
from SimpleHTTPServer import SimpleH... |
HttpError: <HttpError 400 when requesting https://www.googleapis.com/bigquery/v2/projects/
Question: Here is the error dat i'm getting while trying to make an authentication call
to bigquery
HttpError: <HttpError 400 when requesting https://www.googleapis.com/bigquery/v2/projects/ClientId/datasets/sample... |
Navigating JSON objects in a generic way in Haskell
Question: My goal is to write a program in Haskell that takes the name of a json file
and interprets the rest of the arguments as a path to navigate that json file
by and print the value navigated to. The problem is because JSON can contain
multiple value types, I don... |
Acess modules from different directory
Question: I have the following file structure
python/
A/
a.py
b.py
B/
c.py
So there are two folders A and B under the folder python and I want to import
modules from a.py and b.py - import them in c.py ( B fo... |
Why are Python builds suddenly not Framework builds when using virtualenv?
Question: I've installed Python 2.7 as a Framework build on my Mac. I've installed and
confirmed that wxPython works with this Python build. But when I create a
virtual environment with virtualenv, the resulting Python executable isn't a
Framewo... |
Redirecting the output of a python function from STDOUT to variable in Python
Question: This is what I am trying to achieve
def fun():
runner = InteractiveConsole()
while(True):
code = raw_input()
code.rstrip('\n')
# I want to achieve the following... |
Common pathname manipulations to save in a specific directory a file
Question: I am writing a function where I read `inFile` in order to split it into two
files (outFile1,outFile2).
What I want is if `outFile1` and/or `outFile2` are specified without pathname
directory (ex: `outFile1="result1.txt"` and `outFile2="resu... |
Suppress cursor.execute() message in python MySQLdb
Question: How to suppress the cursor.execute() message in MySQLdb.
>>> from warnings import filterwarnings
>>> import MySQLdb
>>> filterwarnings('ignore', category = MySQLdb.Warning)
>>> db = MySQLdb.connect('127.0.0.1', 'root', '','')
>... |
python - matplotlib - How to specify the scale for x axis
Question: > **Possible Duplicate:**
> [Python, Matplotlib, subplot: How to set the axis
> range?](http://stackoverflow.com/questions/2849286/python-matplotlib-
> subplot-how-to-set-the-axis-range)
I would like to specify the scale of the x-axis for my scatte... |
Stop New Relic / Celery From Polluting Logs on Heroku
Question: # Question
How can you stop New Relic / Celery from constantly printing the below to
Heroku's log.
app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
app[scheduler.1]: [INFO/MainProcess] Star... |
Prepending a function docstring with a decorator in python
Question: How would you be able to prepend a functions docstring with a decorator?
def g(func):
someOtherDocString = "That is great"
def wrap(*args, **kwargs):
func(*args, **kwargs)
return wrap
@g
def ... |
Scapy PcapReader and packets time
Question: I'm reading a PCAP file using Scapy using a script such as the (semplified)
following one:
#! /usr/bin/env python
from scapy.all import *
# ...
myreader = PcapReader(myinputfile)
for p in myreader:
pkt = p.payload
print pkt.time
... |
Running Salome script without graphics
Question: I exported a script from Salome (dump), and I want to run it in python (I'm
doing some geometric operation and I don't need any graphics). So I removed
all the graphic command, but when I try to launch my python file, python
cannot found the salome libraries.
I tried to... |
Python - Accessing subclasses' variables from parent class while calling classmethods
Question: i'm trying to build sort of a "mini django model" for working with Django and
MongoDB without using the norel Django's dist (i don't need ORM access for
these...).
So, what i'm trying to do is to mimic the standart behavior... |
How can I get a class object/instance from a previous __import__ in Python?
Question: Let's suppose you have a module named "module" inside a hirearchical "folder2"
with a class named "klass".
How can I get the class like in a square bracket syntax?
module = __import__('folder1.folder2.module', fromlist... |
Python/Django: automatically log when exceptions occur, including request info
Question: I have created a function log_error(request, traceback), which I call in my
exceptions. This writes error information to the database. Now, before I open
up every one of my views and add this in an exception handler, is there a way... |
Is there a way to use PhantomJS in Python?
Question: I want to use [PhantomJS](http://phantomjs.org/) in
[Python](http://www.python.org/). I googled this problem but couldn't find
proper solutions.
I find `os.popen()` may be a good choice. But I couldn't pass some arguments
to it.
Using `subprocess.Popen()` may be a ... |
How to pass parameter to Url with Python urlopen
Question: I'm currently new to python programming. My problem is that my python program
doesn't seem to pass/encode the parameter properly to the ASP file that I've
created. This is my sample code:
import urllib.request
url = 'http://www.sample.co... |
PyYAML, how to align map entries?
Question: I use PyYAML to output a python dictionary to YAML format:
import yaml
d = { 'bar': { 'foo': 'hello', 'supercalifragilisticexpialidocious': 'world' } }
print yaml.dump(d, default_flow_style=False)
The output is:
bar:
foo: hell... |
halt processing of program AND stop traceback?
Question: I have a program that needs to stop processing altogether once a certain
condition has been triggered - similar to this question: [How do I abort the
execution of a Python script?](http://stackoverflow.com/questions/179369/how-
do-i-abort-the-execution-of-a-pytho... |
Install missing dependencies for scipy
Question: I'm trying to install scipy but when I finish installing, I can't import it.
is there any GUI for easy installation?
The general information:
Windows 7 - Python 2.7 - scipy 0.11.0 - I followed the steps in
abel.ee.ucla.edu/cvxopt/install/index.html) for windows to in... |
How do I import a pre-existing python project into Eclipse?
Question: I am using eclipse for python. How do I import an existing project into
eclipse in the current workspace.
Thanks
Answer: New Project
Dont use default Location
Browse to existing project location ...
if its an existing eclipse project with proje... |
Preserve colored output from python os.popen()
Question: I'm using Python to build multiple VS solutions from a given directory using
msbuild.exe. I only want specific output, but to save work, the best way to
interpret the results is with the original ANSI encoding.
Example:
import os
output = os.p... |
python fail to display list of modules
Question: I have new installation of ubuntu 12.04 64-bit. I have python 2.7 and
installed python 3.3 as python3 up to now did not have problems, but
installation is fairly new. When I try to check modules I installed by using
`help('modules')` I have an error:
Pytho... |
which module to automating Voice/Speech using python
Question: I wanted to automate voice using python not able to find the module which can
automate voice or speech.
Answer: Take a look at [pyspeech](http://code.google.com/p/pyspeech/). I think this is
what you are looking for, speech automation. But this is only fo... |
OS path insert command
Question: There are some problems using the PYTHONPATH env variable. Therefore I have to
figure out some other option in my code to import modules from another folder.
I was trying the sys.path,insert based on "TEST_INSTALL_DIR" env variable (
value=C:\test).
I want to create
path... |
OOP in gui testautomation scripts
Question: I'm working on a test automation for a web gui. It's a large product so it's
important to design a good software architecture. First i have decided to
isolate test data from test logic. After that i want to build classes in oop
style which helps to handle changes in short tim... |
can you recover from reassigning __builtins__ in python?
Question: If I open up interactive mode and type:
__builtins__ = 0 # breaks everything
have I completely broken the session? If so, what is going on behind the
scenes to assign __builtins__ to the builtin module that can't be handled by
the i... |
How can I add background color inside html code using beautifulsoup?
Question: With beautifulsoup I get the html code of a site, let say it's this:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
How I... |
Why isn't print(\a) working in IDLE
Question: **NOTE** I changed the q slightly so that it is not a duplicate anymore.
Sorry.
I have these time-consuming bioinformatics scripts I am running. I'd like them
to sound a beep when they are done.
I am on OS X.
In a [similar thread](http://stackoverflow.com/questions/65374... |
Write Integer to XML Node in minidom
Question: I'm using minidom in Python to create an XML formatted log file for completed
tasks. Part of the process is to compare the last modified time of a file to
the time that that files data was recorded into the log. I plan on doing that
via:
if modTime < recTime... |
Suppressing pjsua output in Python script
Question: I'm writing a script that uses curses to produce a main window and a log
window at the bottom of the screen.
It seems that when I import pjsua it insists on printing to the screen even
though I have set log level to 0. Here's what it outputs:
15:49:09.... |
PySide QGLBuffer allocate input data
Question: I'm trying to run PySide version of OpenGL Core Profile Qt demo -
[How_to_use_OpenGL_Core_Profile_with_Qt](http://qt-
project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt).
It uses QGLBuffer.allocate() method (C++ code)
float points[] = { -0.5f, -0.5f, 0... |
How to catch all errors and have reference to what's been thrown?
Question: I've read this article <http://docs.python.org/2/tutorial/errors.html> two
times to make sure. It avoids the topic entirely.
1. I've tried throwing something which is not an `Exception` or `ExceptionBase`, the interpreter told me I can only ... |
Installing Python setup tools on Unix to run Tweepy Twitter client for Python
Question: I am trying to run Tweepy client for Twitter on my Unix account. whenever i
try to run setup for Tweepy using the command:
python setup.py
I get this error:
Traceback (most recent call last):
... |
Converting a command line program to a GUI
Question: I created a python script for a simple call with 19 functions. I'm having
problems as it won't work in GUI mode. Do I have to recode the whole thing? I
don't know much about GUI. Could someone help me here please. I've tried
reading about GUI I'm just lost with the s... |
Throwing n dice m times, what is the probability of getting atleast one six
Question: I have the following code trying to solve the problem below:
Thrown n dice m times, calculate the probability of getting at least one 6.
I know that the exact probability of getting at least 1 six when throwing 2
dice is 11/36.
My ... |
Python list sorting and indexing
Question: I am having issue understanding and solving the following issue with lists,
sorting and indexing. Here is the code example:
import random as rdm
a=[]
for i in range(3):
a.append([i,rdm.randint(-5,5)])
print a
b = sorted(a,key=lambda a:a[1... |
python tkinter how to bind key to a button
Question: New to programming and especially python and tKinter. How can I create a way
to bind the key "s" to the button or the function `sharpen`? Any help would be
awesome.
from Tkinter import *
from PIL import Image, ImageTk, ImageFilter, ImageEnhance
... |
Creating .dll from a Python file
Question: > **Possible Duplicate:**
> [py2exe to generate
> dlls?](http://stackoverflow.com/questions/550446/py2exe-to-generate-dlls)
I'm searching for a way to make a .dll-file out of a python file. I also
wonder if I can use the functions in the dll from an another language like C... |
Using python Popen to read the last line
Question: I have a simple python program:
test.py:
import time
for i in range(100000):
print i
time.sleep(0.5)
I want to use another program that executes the above one in order to read the
last line output while the above program is cou... |
How to make a pyparsing grammar dependent on an instance attribute?
Question: I’ve got a pyparsing issue that I have spent days trying to fix, with no luck.
Here’s the relevant pseudocode:
class Parser(object):
def __init__(self):
self.multilineCommands = []
self.grammar ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.