text stringlengths 226 34.5k |
|---|
FindWindow fails
Question: I've troubles with `FindWindow` using `pywin32` extension. Simple C code:
int main()
{
HWND h = FindWindow(NULL, TEXT("SomeApp"));
if (h != INVALID_HANDLE_VALUE)
SetForegroundWindow(h);
return 0;
}
Works well. Same with python:
... |
QtGui.QFileDialog.getExistingDirectory() window won't close after directory has been chosen (PyQt)
Question: I am trying to get a path with the `QtGui.QFileDialog.getExistingDirectory()`
dialog window in a `python` program to ease things up for users while the rest
of the program is in console output. I have this piece... |
Python pass instance of itself as an argument to another function
Question: I have a UserModel class that will essentially do everything like login and
update things.
I'm trying to pass the instance of itself (the full class) as an argument to
another function of another class.
For example: (obviously not the code, b... |
ImportError: No module named pyobjc
Question: I am new to Python. I am running Mac OS X 10.8.2, Python 2.7.3, Xcode 4.5.1. I
am not able to `import pyobjc` to python.I used `easy_install pyobjc` or
manually downloading it from <http://pypi.python.org/pypi/pyobjc/2.3> and
running `python setup.py install`. Here is a scr... |
Complex query with Django (posts from all friends)
Question: I'm new to Python and Django, so please be patient with me.
I have the following models:
class User(models.Model):
name = models.CharField(max_length = 50)
...
class Post(models.Model):
userBy = models.ForeignKey(... |
How to recover python dateutil.rrule object from a dictionary string?
Question: I want to store dateutil.rrule objects to a database and recreate them after
reading from the database.
Given the following issue, I think I need to use a workaround. [Python
dateutils print recurrence rule according to iCalendar format (s... |
What code does Python's timeit(...) method actually time in this bit of code?
Question:
timeit.timeit("A0([randint(1,256) * (-1) ** randint(1,2) for j in range("+str(n)+")])", setup="from HW2 import A0", number=1000000)
I want to measure the time that the A0 algorithm takes to complete its job on
a list of s... |
can I use FUSE with Cython bindings
Question: I know FUSE has bindings for C, C++, Python etc. Which effectively means that
I can develop FUSE filesystems using those languages. I wish to use Cython, as
it offers much faster speeds as compared to pure Python. That is stressed in a
filesystem. Is it possible to produce ... |
UnicodeEncodeError when using os.listdir
Question: * OS: Windows 7, 64-bit
* Python 3.1.3
When I try to do this
os.listdir("F:\\music")
I get this
UnicodeEncodeError: 'gbk' codec can't encode character '\xe3' in position 643: illegal multibyte sequence
`os.listdir` works w... |
Tornado websocket logging
Question: I'm trying to implement websockets using Tornado webserver.
My setup looks as follows:
from tornado.options import options, define, parse_command_line
import django.core.handlers.wsgi
import logging
import tornado.httpserver
import tornado.ioloop
i... |
flask url_for TypeError
Question: I have an error when trying to use the url_for method in Flask. I'm not sure
what the cause of it because I only follow the Flask quick start. I'm a Java
guy with a bit of Python experience and want to learn Flask.
Here's the trace:
Traceback (most recent call last):
... |
Python script that gets my latest tweet stopped working on my server
Question: Consider the following code:
import twitter
api = twitter.Api()
most_recent_status = api.GetUserTimeline('nemesisdesign')[0].text
On my server (nemesisdesign.net) stopped working a few days ago.
If I try the sam... |
Python 3: creating a Letter Pyramid
Question: I'm trying to create a text pyramid with a height of 291 lines. By this I
mean:
Here is an example of a pyramid of height 6:
-----a-----
----bcd----
---efghi---
--jklmnop--
-qrstuvwxy-
zabcdefghij
Notice: ... |
Python log time window
Question: I was asked to edit a script that would allow you time print out a time window
of information from a log file. I am having a hard time figuring out what
would be the best way of going about this. The logs have the time at the start
of the log as follows:
[11-Oct-2012 07:4... |
Read from a gzip file in python
Question: I've just make excises of gzip on python.
import gzip
f=gzip.open('Onlyfinnaly.log.gz','rb')
file_content=f.read()
print file_content
And I get no output on the screen. As a beginner of python, I'm wondering what
should I do if I want to read th... |
How to match a string against a set of wildcard strings efficiently?
Question: I am looking for a solution to match a single string against a set of wildcard
strings. For example
>>> match("ab", ["a*", "b*", "*", "c", "*b"])
["a*", "*", "*b"]
The order of the output is of no importance.
I will... |
Country name from ISO short code in dictionary, how to deal with non-ascii chars
Question: I'm making a webapp that takes country short code (google app engine get from
request header) and I want to get the country name (full name) not just the 2
letter initials.
I tried making a python dictionary but it breaks bkz th... |
Transformed Data Takes up 4x more space for a doubling of variables in pandas for python
Question: I've performed some simple z-transforms on some variables I have in a pandas
DataFrame. There was a total of 216 columns in the dataframe, I transformed
196 of them and then concatenated the 197 onto the original 216 for ... |
Unit test python udev interaction
Question: I've inherited some python code that writes a new '/etc/udev/rules.d' mapping
file and then makes a subprocess call to udev to have it refresh its devices
list:
call(['/sbin/udevadm', 'trigger', '--action=change'])
The trigger call is necessary as we need... |
JDBC driver not found error in monkeyrunner/jython
Question: I need to Insert something in the `DB`. im using `JDBC` as a `connector,
jython the script`, `mysql` the DB and the script is running in `CentOS`.
my code looks something like this:
> from `com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
> Monke... |
Issues with translating the strings
Question: I am using **multiple translation** in my project
For that I have updated my **settings file** as
LANGUAGE_CODE = 'en-us'
gettext = lambda s: s
LANGUAGES = (
('es', gettext('Spanish')),
('en', g... |
wxPython: Problems with GridBagSizer
Question: I'm new to wxpython and it seems to be very powerful tool for building up GUI,
but I have a question about GridBagSizer. Could you please tell me how to
adjust the size of the items that are placed inside GridBagSizer to the size
of the frame they are supposed to be placed... |
Python: is the system function too slow?
Question: I have a small network with 3 computers. I have a C++ program on the 2nd
computer that reads packets from a network interface while the first computer
sends it data. I need to run that from the third computer. I wrote a small
python script using `flask`
... |
Spynner doesn't load html from URL
Question: I use spynner for scraping data from a site. My code is this:
import spynner
br = spynner.Browser()
br.load("http://www.venere.com/it/hotel/roma/hotel-ferrari/#reviews")
text = br._get_html()
This code fails to load the entire html page.... |
How to share secondary y-axis between subplots in matplotlib
Question: If you have multiple subplots containing a secondary y-axis (created using
_twinx_), how can you share these secondary y-axis between the subplots? I
want them to scale equally in an automatic way (so not setting the y-limits
afterwards by hand). Fo... |
looping over large csv python
Question: I have a large csv-file(several hundreds of lines) containing following
structure:
_filename, sitename, servername_
this csv-file contains several doubles, since the servernames are those from a
cluster(always the same couples) and language-aliases for the sitenames(eg.
mijnhu... |
Sorting: Return an array with new positions of each element
Question: I need to sort an array whilst also returning an array which contains the
sorted positions of the original elements. (N.B. not an argsort, the indexes
to sort the array)
At present this requires two steps:
1. An argsort
2. A scatter operation o... |
Importing a class to another class in python
Question: I am trying to learn python i tried to import a class in another class but it
is not working
`Application.py`:
class Application:
def example(self):
return "i am from Application class"
`Main.py`
class M... |
PyQt4 QPixmap Rotating Jpg according to EXIF
Question: Consider [simple `PyQt4` app, loading picture with
`QPixmap`](http://zetcode.com/tutorials/pyqt4/widgets2/) and [scaling with
ratio](http://stackoverflow.com/a/9351984/544721).
Crucial part of code:
from PyQt4 import QtGui, QtCore
(...)
pixm... |
Python - Twisted and PyAudio + Chat
Question: I've been playing around with the Twisted extension and have fooled around
with a chat room sort of system. However I want to expand upon it. As of now
it only support multi-client chats with usernames ect. But I want to try and
use the pyAudio extension to build a sort of ... |
Weird Error in scrapy (CENTOS 6.2)
Question:
>>> import scrapy
>>> from scrapy.selector import HtmlXPathSelector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/Scrapy-0.14.4-py2.7.egg/scrapy/selector /__init__.py", line 28, i... |
Python 3.2.3 running error
Question: I using this code to get the organization in ip address
import urllib
import lxml.html as lh
req= urllib.Request("http://www.ip-address.com/ip_tracer/157.123.22.11", headers={'User-Agent' : "Magic Browser"})
html = urllib.urlopen(req).read()
doc = lh.... |
Change/Add payload existing TCP packages?
Question: I want to change the payload of all existing outgoing packets, so all packets
that have "wordA" in it will be changed to "wordB", this will be done by a
regex match.
I tried Python's scapy, but I don't know how to get it working.
PS: There won't be any wifi involved... |
Get a list of object properties from list of objects in python
Question: I will give you my specific example but this is a general python question.
I have a list of apscheduler job objects
[Link](http://packages.python.org/APScheduler/modules/job.html) I am trying to
figure out what is the most efficient way to get a ... |
input with delimiters in python
Question: I have a problem with the following specification:
**Input:**
First line contains an integer N , the number of element in the given sequnce.
Then follows N integers A1, A2.... An, Ai is ith element of the given
sequence. These numbers may be either space separated or newline ... |
OpenCV Python single (rather than multiple) blob tracking?
Question: I've been trying to get single color blob tracking thru OpenCV on Python. The
below code is working, but it finds the centroid of all the tracked pixels,
not just the centroid of the biggest blob. This is because I'm taking the
moments of all the pixe... |
handing Null return in rpy2
Question: I am using rpy2 to call R function from python.
from rpy2.robjects import *
result=r.someFunctioninR() #someFunctioninR is a R function written by myself
if result==r('as.null()'):
do something
else:
do something else
The "result... |
Using python to parse XML file
Question: I have a python module that was already written for me to download and parse
data from googles patent listing. The code works great until I do anything
before 2005. I have no knowledge of python except how to run the module. How
do I fix it?
The traceback I receive is:
... |
Python 2.6 - Parse arguments
Question: Problem: Need to parse some specific arguments which could be in any order,
non are optional: -h -d -src -dst
Am new to Python and have looked at the alternatives such as getopt and
argparse but couldn't get a working example so went custom as below;
argv=sys.argv[... |
Import error of Cephes Scipy library within WinPython
Question: I'm trying to test the [WinPython
environment](http://code.google.com/p/winpython/), a portable Python
environment, in order to create a version featuring more packages.
I'm working in Windows Vista 32 bit (but the underlying CPU is 64 bit),
Service Pack ... |
Activating and Disabling button after process in python and pyGTK
Question: Essentially, I am trying to make a button "active" first, run a process, and
then after that process has finished running, disable the button again.
Using pyGTK and Python, the code in question looks like this...
self.MEDIA_PLAY... |
Python decoding errors with BeautifulSoup, requests, and lxml
Question: I'm attempting to pull some data off a popular browser based game, but am
having trouble with some decoding errors:
import requests
from bs4 import BeautifulSoup
r = requests.get("http://www.neopets.com/")
p = Beauti... |
I keep getting ValueError: frequency must be in 37 thru 32767 on Python with Winsound
Question: This is the code I have:
import winsound from myro import *
def main():
HftM1 = makeSong("REST 1; REST 1; REST 1; REST 1; REST 1; REST 1; REST 1; REST 1; D4 1/6; F4 1/6; D5 2/3; D4 1/6; F4 1/6; D... |
Return XML Values from Multiple Files in Python?
Question: So I am working on a browser based program, written in Python, that parses XML
data from multiple files in a directory, then returns the values of certain
XML tags on the page. I have successfully been able to return the values from
one of the XML files, but am... |
Number of pages of a word document with Python
Question: Is there a way to get efficiently the number of pages of a word document
(.doc, .docx) with Python ?
And for an .odt file ?
I want to use this for a web application based on Web2py on Linux.
Thank you !
Answer: Only for those who search for this blog entry..... |
Python 3 - reading text from a file
Question: This is exercise 15 from Learn Python the Hard Way, but I'm using **Python
3**.
from sys import argv
script, filename = argv
txt = open(filename)
print ("Here's your file %r:") % filename
print txt.read()
print ("I'll also ask yo... |
how do I search for an xml tag with the matching closing tag?
Question: I'm wondering what is the best way in python to search & delete an XML tag,
content inside it(whatever it is doesn't matter) as well as its closing tag?
XML is well formed as well.
Answer: You could identify the element with XPath and then use th... |
Python multiprocessing - probably failure when method name pass to Process
Question: I have problem with multiprocessing. Under you have the code (he's in couple
of class and files, but i simplified it). I suppose, that problem lies in pass
method name which I want to multiply in multiprocessing.
Informations: "args"... |
trouble plotting function
Question: Im trying to write a function, and then plot it. I am new to python and am
having some trouble. I have to be missing information, just not sure where.
Can anyone help?
xv= arange(-4,5,1)
def f(x):
if (x<0):
return log(x)
elif (0<=x<2):... |
Handling French text Python
Question: I am trying to read some French text and do some frequency analysis of words.
I want the characters with the umlauts and other diacritics to stay. So, I did
this for testing:
>>> import codecs
>>> f = codecs.open('file','r','utf-8')
>>> for line in f:
...... |
Trying to use PyOpenGL and having problems
Question: I am following the tutorial from
<http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml>
The problem is I am using PyOpenGL 3.0.2, which when I import OpenGL from
python3.2 it works perfectly fine. I just can't find a way to get OpenGL
context working for... |
all() returns different values for the same expression
Question: I'm facing a very weird problem in my python script when I use the function
`all()`.
The console gives me `false` (which is obviously correct) for this line:
all(x == 2 for x in (8,2,2,2))
and in my script the same line returns `true... |
Errors in program for calculating integrals
Question: I am trying to calculate the area of a graph using integrals.
The user is supposed to give me 3 numbers:
* x1, x2 - the bounds of the integral
* N is in how many pieces the program will divide the function
However, I keep getting wrong results.
The first di... |
How to create a two-dimensional array in Python?
Question: I want to create 2-d array in python like this:
n1 n2 n3 n4 n5
w1 1 4 0 1 10
w2 3 0 7 0 3
w3 0 12 9 5 4
w4 9 0 0 9 7
Where w1 w2... are the different words and n1 n2 n3 are diff... |
How to check if my list has an item from another list(dictionary)?
Question: I'm a beginner in programming with python, and I've got a question which may
have an easy answer.
So I have a dictionary of words which is imported from a .txt file, next my
program asks you to type a sentence, and then it saves every word wh... |
Using readlines in python? First time
Question: I have a text file with columns of data and I need to turn these columns into
individual lists or arrays. This is what I have so far
f = open('data.txt', 'r')
temp = []
for row in f.readlines():
Data = row.split()
temp.append(float(D... |
Python: Get random value from a array dimension
Question: I am trying to get a random element from an array's single dimension in
Python. So in the case below, I would like to retrieve any one of the 5
floats.
ar = rand(1, 5)
ar = array([[ 0.29889882, 0.84955019, 0.52989055, 0.57220576, 0.16... |
OpenCL Matrix Multiplication - Getting wrong answer
Question: here's a simple OpenCL Matrix Multiplication kernel which is driving me crazy:
By the way I am using pyopencl.
__kernel void matrixMul( __global int* C,
__global int* A,
__global in... |
Using BeautifulSoup Library with Python
Question: I'm following a tutorial on creating a map using Python and the Beautiful Soup
library.
I have downloaded beautiful soup and the folder is called
"beautifulsoup4-4.1.3". The contents of this folder are in the attached image.
During the tutorial I am given the followin... |
Iterate through XML to get all child nodes text value
Question: i have a xml with following data. i need to get value of and all other
attribute. i return a python code there i get only first driver value.
My xml :
<volume name="sp" type="span" operation="create">
<driver>HDD1</driver>
<... |
How to get data from the TreelView list
Question: [http://www.vliz.be/vmdcdata/mangroves/aphia.php?p=browser&id=235056&expand=true#ct](http://www.vliz.be/vmdcdata/mangroves/aphia.php?p=browser&id=235056&expand=true#ct)
(That's the information I am trying to scrape)
**I wanna to scrape this detailed taxonomic trees so ... |
gnuplot - Histogram with histeps connects bars
Question: This is a minimal working example of the code I'm using:
#!/bin/bash
gnuplot << EOF
set term postscript portrait color enhanced
set encoding iso_8859_1
set output 'temp.ps'
set grid noxtics noytics noztics front
set si... |
Identify a shape inside another shape using AForge.Net
Question: I am using the AForge.Net library to do some basic image processing stuff as
part of a project. I have found it trivial to identify individual geometric
shapes in an image (like a square, circle etc.,). However when I have an image
like . I've read
through the entire documentation sheet, but didn't see how this could be done.
I have a timezone: America/Chicago. All I want is to get the respective
country code for this timezone: US.
I... |
Which is the preferred method to use jinja2 on App Engine?
Question: I originally implemented Jinja2 on App Engine using the examples shown on the
App Engine site here:
<https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates>
where jinja2 is imported directly:
import jinja2
... |
Streaming continuous data over a network with python
Question: I have a device that continually outputs data and I would like to send that
data to a client on the same network as it is produced and I'm not finding a
good solution. Here is what I'm trying.
Server:
import SocketServer
from subprocess ... |
Embed Python HTTP server into C program as RPC server?
Question: I have a program written in C++ with a web interface to for the purpose of
RPC. I can call `http://localhost/ListVariables` or
`http://localhost/RunFunction?var=1` and have the C code execute ListVariables
or RunFunction. It works, but I'd rather not have... |
While loop waiting for input python
Question: I have a question about while loops in python. I want to make a program that
performs a while loop in a certain time.I want to add the extra feature that
while the program us running,a certain variable can be changed by pressing a
random key.
from time imp... |
Interfacing with TUN\TAP for MAC OSX (Lion) using Python
Question: I found the following tun\tap example program and can not get it to work:
<http://www.secdev.org/projects/tuntap_udp/files/tunproxy.py>
I have modified the following lines:
f = os.open("/dev/tun0", os.O_RDWR)
ifs = ioctl(f, TUNSETIF... |
Permission issue for apache
Question: Environment Details:
Amazon Ec2 Ubuntu 12.04
Django + mod_wsgi + python 2.6
web server: apache2
I have mounted a `10GB` `ebs volume` to an instance to `/mnt/ebs1/`. After
mounting the volume and formatting, I have placed all my project files in
`/mnt/eb... |
Running Python scripts on local machine
Question: I am trying to run a simple hello world example in python that runs against
mongodb. I've set up mongo, bottle and pymong and have the following script
inside `C:\Python27\Scripts`:
import bottle
import pymongo
@bottle.route('/')
def... |
Python calendar: day/month names in specific locale
Question: I am playing with Python's
[calendar](http://docs.python.org/library/calendar.html) module that's in the
standard library. Basically I need a list of all days of a month, like so:
>>> import calendar
>>> calobject = calendar.monthcalendar(... |
Python Regular Expression for validate numbers
Question: I want to create a regular expression for python snippet.
import re
pattern = "\d*\.?\d+[Ee]?[+-]?\d*"
r = re.compile(pattern)
txt = """
12
.12
12.5
12.5E4
12.5e4
12.4E+4
12E4
12e-4
"""
x = r.find... |
unable to call firefox from selenium in python on AWS machine
Question: I am trying to use selenium from python to scrape some dynamics pages with
javascript. However, I cannot call firefox after I followed the instruction of
selenium on the pypi page(http://pypi.python.org/pypi/selenium). I installed
firefox on AWS ub... |
how do I get momoko working?
Question: I am new to python and even newer to tornado/momoko. I am struggling with an
example from [momoko's
website](https://github.com/FSX/momoko/blob/master/examples/gen_example.py). I
have the database.cfg file configured with my settings.
#!/usr/bin/env python
impor... |
DataFrame Indexing with a date series
Question: I'm new to Python and Pandas, and am having some trouble indexing by a date
series. I am trying to pull data into a DataFrame from a SQLite db that
consists of a date in format 'mm/dd/yyyy' and an equity price. I then create a
new DataFrame using set_index to index the pr... |
python parse conditional xml value
Question: Here is my XML file:
<METAR>
<wind_dir_degrees>210</wind_dir_degrees>
<wind_speed_kt>14</wind_speed_kt>
<wind_gust_kt>22</wind_gust_kt>
</METAR>
Here is my script to parse the wind direction and speed. However, the wind
gust is a conditio... |
Can't compile python bindings using boost-python on OS X
Question: I try to do python bindings on C++ using boost-python, but I can't compile and
I can't find out why.
I'm using a code sample from boost-python `hello.cpp`:
// Copyright Ralf W. Grosse-Kunstleve 2002-2004. Distributed under the Boost
... |
Python Scrapy function to be called just before spider_closed signal sent?
Question: I wrote a spider using scrapy, one that makes a whole bunch of
HtmlXPathSelector Requests to separate sites. It creates a row of data in a
.csv file after each request is (asynchronously) satisfied. It's impossible to
see which request... |
linker command failed at fastmath installing pycrypto on OSX
Question: I did `pip install pycrypto` (actually wanted to install `fabric` but it
failed at pycrypto) and got the error below. I'm on python 2.7.3. Tried 3.3
too but same error. How do I fix this please?
My clang version:
$ clang --version
... |
How to print module documentation in Python
Question: I know this question is very simple, I know it must have been asked a lot of
times and I did my search on both SO and Google but I could not find the
answer, probably due to my lack of ability of putting what I seek into a
proper sentence.
I want to be able to read... |
FFTW3 on complex numpy array directly in scipy.weave.inline
Question: I am trying to implement an FFT based subpixel shifting (translation)
algorithm in `Python`. The Fourier shift theorem allows an array to be
translated by a subpixel amount by: 1\. Forward FFT array 2\. Multiply array
by linear phase ramp in Fourier ... |
Cannot create browser process when using selenium from python on RHEL5
Question: I'm trying to use selenium from python but I'm having a problem running it on
a RHEL5.5 server. I don't seem to be able to really start firefox.
from selenium import webdriver
b = webdriver.Firefox()
On my laptop w... |
Python embedded in c . Is calling PyRun_SimpleString synchronous?
Question: people. I would be grateful if you can help me. The application's purpose is
to translate lemmas of words present in the sentence from Russian to English.
I'm doing it with help of sdict formatted vocabulary, which is queried by
python script w... |
Find whether a numpy array is a subset of a larger array in Python
Question: I have 2 arrays, for the sake of simplicity let's say the original one is a
random set of numbers:
import numpy as np
a=np.random.rand(N)
Then I sample and shuffle a subset from this array:
b=np.array() ... |
Using Flask-SQLAlchemy in Blueprint models without reference to the app
Question: I'm trying to create a "modular application" in Flask using Blueprints.
When creating models, however, I'm running into the problem of having to
reference the app in order to get the `db`-object provided by Flask-
SQLAlchemy. I'd like to... |
can you print a file from python?
Question: Is there some way of sending output to the printer instead of the screen in
Python? Or is there a service routine that can be called from within python to
print a file? Maybe there is a module I can import that allows me to do this?
Answer: Most platforms—including Windows—... |
calling python module dynamically using exec
Question: I have 2 modules
mexec1.py
def exec1func():
print 'exec1'
exec 'c:/python27/exec2.py'
if __name__ == '__main__':
exec1func()
exec2.py
def exec2func(parm=''):
print 'exec2 parm',parm
... |
In Python, how can I increment a count conditionallly?
Question: Say I have the list:
list = [a,a,b,b,b]
I'm looping over the list. The variable "count" increments by 1 when the
previous letter is the same as the current letter. Below is only part of the
code:
for item in list:
... |
convert a dict to sorted dict in python
Question: I want to convert a dict into sorted dict in python
data = pandas.read_csv('D:\myfile.csv')
for colname, dtype in data.dtypes.to_dict().iteritems():
if dtype == 'object':
print colname
count = data[colname].value_counts... |
when does import module at bottom of file
Question: when I read a file `riak-python-client/riak/riak_object.py`. At the bottom of
the file, I saw this
from mapreduce import *
what's it use for? Why just import at the top of the file.
Answer: This is designed to put all of the module `mapreduce` i... |
implementation of command line arg passing in python, doesn't work
Question: I'm very new to python. I wish I could implement the command-line arg passing
in python as my first python script. I have written this code:
def main(argv):
try:
opts, args = getopt.getopt(argv, "hb:b:f", ["h... |
Parallelise python loop with numpy arrays and shared-memory
Question: I am aware of several questions and answers on this topic, but haven't found a
satisfactory answer to this particular problem:
What is the easiest way to do a simple shared-memory parallelisation of a
python loop where numpy arrays are manipulated t... |
how to use webkit code in scrapy/python
Question: In the question at [How to combine scrapy and htmlunit to crawl urls with
javascript](http://stackoverflow.com/questions/8047666/how-to-combine-scrapy-
and-htmlunit-to-crawl-urls-with-javascript), it is advised to use webkit with
scrapy to go through javascript. However... |
Syntax Error in Dice game
Question: I made this dice game in python, but am getting a syntax error with my
inputdice function. Below is the dice game in its entirety. When run, the game
should go through 10 rounds and stop after round 10 or when the user runs out
of money. Any suggestions?
from random im... |
Call current PyMOL session from python script
Question: I'm trying to call current PyMOL session from python script (wxpython GUI),
and then load some data from PyMOL and send few commands to PyMOL. At the
moment I can open a new PyMOL session in python script:
import sys, os
from wx import *
app... |
How to stop the program when the output fills the screen in python?
Question: How can I get the status of the terminal from a Python program? I want the
program to stop printing lines to the screen when the screen is full and wait
for user input.
Answer: The simplest (no code) way to accomplish that is to pipe your p... |
python struct pack with space padding
Question: I need to create/send binary data in python using a given protocol. The
protocol calls for fixed width fields , with space padding thrown in. Using
python's struct.pack, the only thing I can think of is, calculating the space
padding and adding it in myself. Is there a be... |
reading column from excel and doing specific math
Question: I have an excel file that has 27 columns. I want to write a python code which
reads column by column and stores the final 5 values in the coloum which will
have math equations done on them.
I have this so far:
from math import tan
#Wri... |
How to iterate over each pair of items in a dictionary
Question: I'm making a gravity simulator and I need to calculate the resultant force
acting upon each body.
In order to do this, I need to iterate through every pair of bodies in a
dictionary `(id: instance of Body class)` and get the gravitational force
between t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.