text
stringlengths
226
34.5k
Extracting Tags from BeautifulSoup Question: I am trying to get the Body-Tag from <http://feeds.reuters.com/~r/reuters/technologyNews/~3/ZyAuZq5Cbz0/story01.htm> but BeautifulSoup doesn't find it. Is this because of invalid HTML? If so, how can I prevent this? I also tried to prefix HTML-Errors using PyTidyLib (<http...
ValueError with Python and Numpy Question: I'm trying to rebuild a song in python, but I cannot concatenate the notes of the same. I get this error: > **ValueError** : operands could not be broadcast together with shapes (0) > (1250) Here's my code: import numpy as np, matplotlib.pyplot as plt ...
How to refresh a browser tap after time.sleep in python Question: So this is what I'm using to open the browser import webbrowser import time url = "http://google.com" time = 5 def TestBrowse(url,time): webbrowser.open(url) time.sleep(time) I want a functio...
How to integrate SimpleGUI with Python 2.7 and 3.0 shell Question: I am learning Python from Coursera. In this course they use **SimpleGUI** module on [CodeSkulptor](http://www.codeskulptor.org/). Can anyone tell me how to integrate SimpleGUI with python 2.7 and 3.0 shell? Answer: You can just use SimpleGUITk (<http:...
Double the length of a python numpy array with interpolated new values Question: I have an array of 5 numbers: A = [10, 20, 40, 80, 110] I need to create a new array with a 10nth length numbers. The extra numbers could be the average number between the two # of `A`. for example: EDIT B = [10 , 15...
Can python-igraph be used for min s-t cut? Question: Can Python-igraph be used to do min s-t cut? I want the minimum cost cut that cuts the designated source and sink nodes. Thanks! Answer: Yep. from igraph import Graph from random import randint g = Graph.GRG(100, 0.2) # generate a ge...
Python 3.3 + Matplotlib 1.2.0: pdf export generates "'str' does not support the buffer interface" error Question: I just started migrating from matlab/mathematica to python for technical computing. I have been learning how to use the matplotlib.pyplot package and was hoping someone could help me with fonts. I ultimatel...
Retriving a tag value from multiple XML files in a directory using python Question: I am currently learning python to automate a few things in my job. I need to retrieve a tag value from multiple xml files in a directory. The directory has many subfolders too. I tried the following code, and understood what is missing...
How to use a C dll in python Question: I am trying to use a C++ dll in python. I am running python 2.7 on Windows server 2012; both are 64bit. To create a dll, I followed the directions on "Walkthrough: Creating and Using a Dynamic Link Library (C++)" on <http://msdn.microsoft.com/en- us/library/vstudio/ms235636.aspx>...
PyInstaller created exc. does not run on virtualbox with ubuntu Question: I used PyInstaller to create an executable from a GUI script I wrote (using wx.python) using this command... python /home/torosean/pyinstaller/pyinstaller.py -F -w My_GUI_login_simplified.py I can run the executable on the...
Python - connection.close() - SyntaxError: invalid syntax Question: I am trying to create quote of the day server, and I am having a problem with sockets. My program code is below: #!/usr/bin/python from socket import * from ConfigParser import * import sys import argparse impor...
I want to run a python script periodically with a variable persisted each repetition. How can I do this? Question: I have a python script which moves a robot based on a bearing. The bearing calculated is relative to another robot. I want to calculate a corrective factor based on the magnetic bearing the robot is moving...
Get body text of an email using python imap and email package Question: I want to retrieve body (only text) of emails using python imap and email package. As per this [SO thread](http://stackoverflow.com/questions/3449220/how-do-i- recieve-a-html-email-as-a-regular-text?rq=1), I'm using the following code: ...
executing current python file in vim creates new file if current time is parsed Question: I am executing python files from vim as described here: [How to execute file I'm editing in Vi(m)](http://stackoverflow.com/questions/953398/how-to- execute-file-im-editing-in-vim) I observe the same behavior on Windows & Linux. ...
PyCharm How to import module from network share Question: I'm running PyCharm 2.7.2 on Windows7 with interpreter v2.7.4 I need to import a module that lives on a network share. I believe the PyCharm way of doing this is to add another 'Content Root'. However PyCharm only presents the C drive in the Add Content Root di...
Django import error - bad argument to internal function Question: I'm making a basic time-card program. I'm getting an error while importing views from urls.py. The other files in the app (models, forms, etc) can be imported, but any call to import views returns an error I haven't seen before. Request Me...
PyMC regression of many regressions? Question: I haven't been using PyMC for long, but I was pleased at how quickly I was able to get a linear regression off the ground (this code _should_ run without modification in IPython): import pandas as pd from numpy import * import pymc data=pd.D...
getting started with cython by using cdef Question: I dont understand how to setup and run code with cython. I added `cdef`, `double`, etc to pertinent pieces of my code. setup.py of course the name hello isn't being used. [cython doc](http://docs.cython.org/src/quickstart/build.html) from distutils.co...
Scraperwiki character encoding anomaly Question: Here is a ScraperWiki scraper written in Python: import lxml.html import scraperwiki from unidecode import unidecode html = scraperwiki.scrape("http://www.timeshighereducation.co.uk/world-university-rankings/2012-13/world-ranking/range/001...
How do I zip a file in python Question: How do I zip a file in python and how do specify the compression level ? I have the below code so far and the error I get is: Zip("log4j.dl-service.log.2013-05-03-22",9) AttributeError: 'str' object has no attribute 'ZipFile' Code: import ...
A good way to make long strings wrap to newline in Python? (3.x) Question: In my project, I have a bunch of strings that are read in from a file. Most of them, when printed in the command console, exceed 80 characters in length and wrap around, looking ugly. I want to be able to have Python read the string, then test ...
Django template: localize number returned from simple tag Question: I hope this question is not here, I have googled it for long time and not found anything. I have problem with formating numbers in templates, but somehow special. Maybe, this is whole problem how to call filters on values returned form simple tags. So,...
Python Regex Mark-Up Question: Hi guys having trouble with a particular problem. I am using python's regex to alter the markup source to output html format. markup source: [ # sometextsometextsometextsometextsometextsometext. # # sometextsometextsometextsometextsometextsometextsometextsom...
NYtimes API, python Question: Hi I want to get all the information after 'title' from NYtimes API, here is my code from urllib2 import urlopen from json import loads import codecs import time def call_the_articles(): url = "http://api.nytimes.com/svc/search/v1/article?query=U...
Sending MMS via MonkeyRunner on Android throws Java exception Question: I need to send MMS by writing a MonkeyRunner script. My script is as below and it throws an exception. Can anyone please help? I am interested in writing scripts using intents and not using co-ordinates method: from com.android.monke...
Python: Importing files based on which files the user wants Question: I have the following directory structure + code | --+ plugins | -- __init__.py -- test_plugin.py (has a class TestPlugin) -- another_test_plugin.py (has a class AnotherTestPlugin) --+ load.py --+...
Python - Extract and reformat field names from rows of data Question: I have a flat text file (infile) that I would like to restructure. It has a few tab-delimited columns and looks something like this: Person1 HEIGHT=60;WEIGHT=100;AGE=22 Person2 HEIGHT=62;WEIGHT=101;AGE=25 Person3 HE...
Why is mmap returning a size of zero? Question: I'm working on a beaglebone (running Angstrom Linux) and trying to use Python's `mmap` module to gain read and write access to the `/dev/mem` file. However, for some reason, the code below prints a value of zero. I'm fairly new to mmap and I'm not sure if there is someth...
I want to save my parsed HTML file into TXT file Question: I've parsed a web page showing article. I want to save the parsed data into text file, but my python shell shows an error like this: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 107: ordinal not in range(128) ...
AttributeError: 'Settings' object has no attribute 'ADMIN_MEDIA_PREFIX' Question: i am trying to make a smart menu using ChainedForeignKey, but so far i am stuck with the import of `ChainedForeignKey`: from smart_selects.db_fields import ChainedForeignKey I am using pydev on Eclipse. I downloaded ...
Python: get int value from a char string Question: This is one of those silly questions and I don't really know how to formulate it, so I'll give an example. I got v = chr(0xae) + chr(0xae) where #AEAE is, in decimal, the value of 44718. My question is how I get the integer value of `v`? I know ab...
Mixin container takes 0 arguments but 2 were passed Question: I am trying to future-proof the css in a [zinnia](http://django-blog- zinnia.com/)-django blog using [compass](http://compass-style.org/), [susy](http://susy.oddbird.net/), and [sass](http://sass-lang.com/). I have successfully copied my zinnia templates int...
Using PyTables from a cython module Question: I am solving a set of Coupled ODEs and facing two problems: speed and memory storage. As such I use `cython_gsl` to create a module which solves my ODEs. Until now I had simply written the data to a `.txt` file but I think it will be more useful to use `PyTables`. As such ...
Replicating .accdb database tables with python pyodbc Question: Novice python user here. There are other ways to achieve this, but I believe this is my best option. I maintain an MS Access 2007 database (.accdb) that is used on offline TabletPCs in the field to collect data. When arriving back at the office, the user c...
z3py on MacOSX: cannot get a model Question: I am seeing a strange problem with z3py on Mac, was wondering if anyone has seen this before: $ cat bug.py from z3 import * x = Int('x') s = Solver() s.add(x > 5) print(s.check()) print(s.model()) $ python bug.py sat ...
How to center this Entry widget? Question: I am starting a project in Python: an email client. I know it may sound odd, but it's just for fun. I have an `Entry` widget and a `Canvas` widget. When I `pack` them both, It gives me the Canvas, and an Entry widget centred above the Canvas, with a border around the Canvas, ...
Cannot get mapnik working with python3, but it does with python2 Question: Here is a post about installing a module in python3. When I use brew install python, then it installs it for 2.7. When I use the method suggested by dan, which aimed to install it directly in python3 (who i really thank), but which didn't work ...
How should I handle this HTTPS request in Python? Question: I am trying to use the [Strava API v3](http://strava.github.io/api/v3/) in Python, and I am afraid I am missing something. The docs say: > This base URL is used for all Strava API requests: <https://api.strava.com> > > `$ curl -i https://api.strava.com` > >>...
FuzzyWuzzy String Matching - Case Sensitivity Question: I'm using the [FuzzyWuzzy String Matching module from SeatGeek](http://seatgeek.com/blog/dev/fuzzywuzzy-fuzzy-string-matching-in- python). I find that when using the token_set_ratio search algorithm, small differences in case gives wildly differing results. For ...
How to delete a dyanmic DNS record using Python or Bash? Question: The Following code in python updates import dns.query import dns.tsigkeyring import dns.update import sys keyring = dns.tsigkeyring.from_text({'host-example.' : 'XXXXXXXXXXXXXXXXXXXXXX=='}) update = dns.update.Up...
Python package: how to avoid redefining author version etc? Question: I would like to distribute a Python package (I would like to use setuptools and I already have a working setup.py file), and the related documentation (produced using Sphinx). I find myself a bit confused by the fact that I have to specify the autho...
Python eTree Parser isn't appending an element Question: Look at my log and see how it says that the row I'm getting back from Postgres has been turned from a string into an element (and I print the string, print the element, print the isElement boolean!) and yet when I try to append it, the error is that it's not an e...
Trouble with printing out of Classes in Python Question: We are supposed to use the code below to print out the parameters listed in it, currently however we are unable to do so and are using a round about method. This is supposed to print out things instead of what we print out in the Game class in the playturn functi...
How to get the name of the top most (entry) script in python? Question: I have a utility module in Python that needs to know the name of the application that it is being used in. Effectively this means the name of the top-level python script that was invoked to start the application (i.e. the one where __name=="__main_...
nose runs test on function in setUp when no suite specified Question: I have a tests file in one of my Pyramid projects. It has _one_ suite with _six_ tests in it: ... from .scripts import populate_test_data class FunctionalTests(unittest.TestCase): def setUp(self): ...
How does python import order affect names? Question: I'm doing a flask tutorial (<http://blog.miguelgrinberg.com/post/the-flask- mega-tutorial-part-i-hello-world>) and I came upon a behaviour that I couldn't explain. The main directory structure of the tutorial is : microblog | |---- app | ...
How to use lzma2 in python code? Question: I know there is a module called pylzma. But it only support lzma, not lzma2. My current solution is using `subprocess.call()` to call 7z program. Is there a better way? Answer: You can use [backports.lzma](https://github.com/peterjc/backports.lzma), see for more info: [Pyt...
Python: Various Lists To Cartesian Product, Variable Length Question: I want to create words or rather combinations from three different arrays. The output should be a Cartesian product with itself and the other array with variable length. Example: array1 = ["a", "b", "c"] array2 = ["x", "y", "z"] ...
How to load in Python-RSA a public RSA key from a file generated with openssl? Question: I generated a private and a public key with the following commands: openssl genrsa -out private_key.pem 512 openssl rsa -in private_key.pem -pubout -out public_key.pem I then tried to load them with a pytho...
Capture mongo shell output using subprocess.Popen Question: I am trying the following: #!/usr/bin/python import os, subprocess func = 'print("Hello World")' x = subprocess.Popen(['mongo', '--eval', func], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=sub...
Python regex -- extraneous matchings Question: I want to split a string using `-`, `+=`, `==`, `=`, `+`, and white-space as delimiters. I want to keep the delimiter unless it is white-space. I've tried to achieve this with the following code: def tokenize(s): import re pattern = re.compile("...
Assign python Decimal objects to MySQL DECIMAL columns Question: I have a table "City" defined as: CREATE TABLE `City` ( `id` int(11) NOT NULL, `lat` decimal(9,6) default NULL, `long` decimal(9,6) default NULL, `lm_index` int(11) default NULL, `num_business` int(11) default ...
Refer to group inside group with Regex Question: I am trying to find a regex that groups a word that ends on two identical symbols followed by 'ter' and splits it on the two symbols. Example: The word 'Letter' should be grouped into 'Let' and 'ter'. I'm using python and this is what i've gotten so far: m...
changing plaintext tags into HTML tags to display in browser in python Question: ok so I'm writing a function in python which takes a text document which is tagged with tags like ===, ==, ---, #text# etc. etc. (alot like wikipedia). Now my program basically has to replace those with HTML tags such as &ndash, &mdash, <>...
Circular import is only stopping Django command, not shell or web response Question: I have two classes which import each other: **profile/models.py** class Company(models.Model): name = ... class CompanyReview(models.Model): company = models.ForeignKey(Company) from act...
Generating (StartDateOfMonth, EndDateofMonth) for every month within date range Question: I want to generate a list of (StartDateOfMonth, EndDateOfMonth) values for a specified date range. e.x. time range: 2011-09-11, 2013-04-24, the list should be : [('2011-9-11', '2011-9-30'), ('2011-10-01', '2011-10-3...
Python: How to use %%% when parsing text Question: I'm trying to parse the text in the ebooks at gutenberg.org to extract info about the books, for example, the title. Every book on there has a line like this: *** START OF THIS PROJECT GUTENBERG EBOOK THE ADVENTURES OF SHERLOCK HOLMES *** I'd lik...
Read Specific Columns from csv file with Python csv Question: I'm trying to parse through a csv file and extract the data from only specific columns. Example csv: ID | Name | Address | City | State | Zip | Phone | OPEID | IPEDS | 10 | C... | 130 W.. | Mo.. | AL... | 3.. | 334.. | 01023 | 10063 | ...
Read python in processing Question: Does anyone know how to read a python file in processing without using processing.py or other third party library or platform? I have a python file that can generate a text and want my processing read it real time. But it seems like there is something wrong with the “loadStrings” stu...
SWIG: difference between %import and %include Question: The [SWIG docs](http://www.swig.org/Doc2.0/Preprocessor.html) explain these two directives as follows: * `%include`: "To include another file into a SWIG interface, use the `%include` directive ... Unlike, `#include`, `%include` includes each file once (and wil...
Permission denied when using cat - even as root? Question: How is it possible I am getting a permission denied using the below? I am using python 2.7 and ubuntu 12.04 Below is my mapper.py file import sys import json for line in sys.stdin: line = json.loads(line) key = "%s:%...
wx.Python: Passing control between multiple panels Question: I'm a newbie to wxPython, and have researched similar questions, but can't specifically find an answer to my question. I'm creating two panels with a splitter. Each panel has a number of widgets. I'd like to have a widget in one panel control some properties ...
Generating a dense matrix from a sparse matrix in numpy python Question: I have a Sqlite database that contains following type of schema: termcount(doc_num, term , count) This table contains terms with their respective counts in the document. like (doc1 , term1 ,12) (doc1, term 2...
Python and zlib: Terribly slow decompressing concatenated streams Question: I've been supplied with a zipped file containing multiple individual streams of compressed XML. The compressed file is 833 mb. If I try to decompress it as a single object, I only get the first stream (about 19 kb). I've modified the followin...
ugettext and ugettext_lazy functions not recognized by makemessages in Python Django Question: I'm working with Django 1.5.1 and I'm experiencing some "strange behaviour" with translations. I'm using `ugettext` and `ugettext_lazy` in the same Python file. If I organize the imports as: from django.utils.t...
Proper way to extract JSON data from the web given an API Question: I have an URL in the form of http://site.com/source.json?s= And I wish to use Python to create a class that will allow me to parse in my "s" query, send it to that site, and extract out the JSON results. I've tried importing json/...
Odd exponent on plotting narrow range of data Question: I get a some very odd behaviour of matplotlib in an ipython notebook when trying to plot this data: [ -142.8916729, -142.89161936, -142.89161954, -142.89162066, -142.89162031, -142.89162033, -142.89162049, -142.89162055, -142...
Bytes to String or String to Bytes? Question: I have read some of the examples here but I am such a novice I don't understand some of them and others don't seem to work(probably because I'm such a novice but... import urllib.request import re Symbols = ['aapl', 'spy' , 'goog' , 'nflx'] i = 0 ...
PythonXY, IPython Qt Console, matplotlib, draw something not in inline mode Question: I'm new to PythonXY and Matplotlib. I installed PythonXY (v2.7.3.1) in default full mode. ![PythonXY](http://i.stack.imgur.com/5FPEQ.png) I use the "IPython Qt Console" application. ![IPython Qt Console](http://i.stack.imgur.com/Mi...
Embed .SVG files into PDF using reportlab Question: I have written a script in python that produces matplotlib graphs and puts them into a pdf report using `reportlab`. I am having difficulty embedding SVG image files into my PDF file. I've had no trouble using PNG images but I want to use SVG format as this produces ...
Trouble getting matplotlib to produce plots Question: I can get matplotlib to work in pylab (ipython --pylab), but when I execute the same command in a python script a plot does not appear. My workspace focus changes from a fullscreened terminal to a Desktop when I run my script, which suggests that it is trying to plo...
Python ImportError: No module named 'path' Question: ''' Data class''' import os.path from random import Random class TestData(object, Random): def FetchDataFromFile(self, filename): """ Open the file as read only """ myfile = open(os.path.join(os.getcwd()...
Connecting to MS SQL Server with Windows Authentication using Python? Question: How do I connect MS SQL Server using Windows Authentication, with the pyodbc library? I can connect via MS Access and SQL Server Management Studio, but cannot get a working connection ODBC string for Python. Here's what I've tried (also w...
I keep getting "InterfaceError: Error binding parameter 0 - probably unsupported type." Question: I am trying to work my way through the official Django tutorial (<https://docs.djangoproject.com/en/1.5/intro/tutorial01/>) but I'm running into a problem when trying to use the shell. Specifically, when I try to run `pyt...
Python save txt file in a different folder Question: the following script is running well and saving the txt output in the Desktop as I am running the script from Desktop. However, I want to save the txt files to my Documents in a new folder named ASCII. How can I give the command for doing that. The 8phases.txt has th...
How to change list into HTML table ? (Python) Question: This is what I have done when there is no HTML codes from collections import defaultdict hello = ["hello","hi","hello","hello"] def test(string): bye = defaultdict(int) for i in hello: bye[i]+=1 retur...
Python pandas plot is a no-show Question: When I run this code import pandas as pd import numpy as np def add_prop(group): births = group.births.astype(float) group['prop'] = births/births.sum() return group pieces = [] columns = ['name', 'sex', 'births'] ...
Python cross-module globale variable Question: I'm new to Python and I was trying out nose as a unit test framework. I came across a behavior I didn't expect, but maybe this is normal, hence my question. I have two (very basic) files: __init__.py: #!/usr/bin/env python glob = 0 def setup()...
Flask-SQLAlchemy InvalidRequestError: Object is already attached to session Question: I'm creating a forum project using Flask, and managing all the users, threads, posts, etc. using Flask-SQLAlchemy. However, I've found that when I attempt to do x (e.g. edit a post), I get an InvalidRequestError if I attempt to do any...
Python: Append a list to an existing list assigned to a key in a dictionary? Question: Lets say I have a dict with key= 'keys' >>> keys 'taste' After a few lines..output >>> {'taste': ('sweet', 'sour', 'juicy', 'melon-like')} This code snippet from collection...
Python Boto created cloud-init #include script not running on EC2 Question: I've run out of ideas, would appreciate some help. I'm starting and EC2 Ubuntu 12.04 instance and adding the following script to the user data: #!/usr/bin/env python import sys from boto.s3.connection import S3...
Variable decimal place limit in function set by user? Question: I just started learning python and am currently writing a script that converts Celsius to Fahrenheit and vise versa. I have the main part done but now I want to be able to let the user set the number of decimals displayed in the output... The first functio...
OverWrite an existing list in CSV files Python Question: I have a csv files with player attributes: ['Peter Regin', '2', 'DAN', 'N', '1987', '6', '6', '199', '74', '2', '608000', '', '77', '52', '74', '72', '58', '72', '71', '72', '70', '72', '74', '68', '74', '41', '40', '51'] ['Andrej Sekera', '8',...
How to convert tuple in string to tuple object? Question: In Python 2.7, I have the following string: "((1, u'Central Plant 1', u'http://egauge.com/'), (2, u'Central Plant 2', u'http://egauge2.com/'))" **How can I convert this string back to tuples?** I've tried to use `split` a few times but i...
Raspberry Pi: how to send serial command using Ethernet? Question: I have a python script, which will start cherrypy webserver when run in the terminal. In the script, i use pyserial by importing `serial`, then i open up the port /dev/ttyAMA0 and i can send any serial commands. @cherrypy.expose def...
Insert a .jpg in a canvas with tkinter and Python 3.2 Question: So I want to put a .jpg in a canvas, all i found on internet is to use PIL but i'm using Python 3.2 so PIL doesn't work. What can i do to insert a .jpg in a canvas with Python 3.2 ? Answer: Just to save anyone else viewing this now from hunting around fo...
Is there an alternative to pickle - save a dictionary (python) Question: I need to save a dictionary to a file, In the dictionary there are strings, integers, and dictionarys. I did it by my own and it's **not** pretty and nice to user. I know about pickle but as I know it is not safe to use it, because if someone _r...
"Underlying C/C++ object has been deleted" Question: I'm having an exception running a simple application in python 2.7 with Qt. Code: # *-* coding: utf-8 *-* __author__ = 'luismasuelli' import sys from PyQt4 import QtGui class StreamWidget(QtGui.QWidget): def __ini...
check if numpy array is subset of another array Question: Similar questions have already been asked on SO, but they have more specific constraints and their answers don't apply to my question. Generally speaking, what is the most pythonic way to determine if an arbitrary numpy array is a subset of another array? More ...
Infoblox WAPI: how to search for an IP Question: Our network team uses [InfoBlox](http://www.infoblox.com/products/ip-address- management) to store information about IP ranges (Location, Country, etc.) There is an API available but Infoblox's documentation and examples are not very practical. I would like to search vi...
Use bat file in CGI Python on localhost Question: I'm quite stuck with with a complex mix of files and languages! The problem: My webform starts a python script, as a cgi script, on localhost(apache). In this python script I want to execute a batchfile. This batchfile executes several commands, which i tested thoroughl...
Trying to send simple messages with zeromq in python between two hosts Question: Script running on machine 1 import zmq context = zmq.Context() socket = context.socket(zmq.SUB) socket.bind("tcp://127.0.0.1:5000") print "socket bound" while True: print "Waiting for me...
Login to google using Python Question: I have been trying for some time now to login to my google account and download a file from it **without using any external libraries**. I am specifically talking about Google Finance (<https://www.google.com/finance>). All I want to do is login, and download my portfolio (after y...
Python list reduction Question: I'm working on a continuously learning focused web crawler to find news articles related to specific crisis and tragedy events that happen around the world. I am currently working on making the data model as lean and efficient as possible considering its constant growth as the crawl cont...
Why does iterative elementwise array multiplication slow down in numpy? Question: The code below reproduces the problem I have encountered in the algorithm I'm currently implementing: import numpy.random as rand import time x = rand.normal(size=(300,50000)) y = rand.normal(size=(300,5000...
How can I slow down a loop in Python? Question: If I have a list l: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Is there a way to control the following _for_ loop so that the next element in the list is only printed one second after the previous? for i in l: print i In other wor...
Python script not work in crontab Question: Here is my script(randombg.py): #!/usr/bin/env python # -*- coding: utf8 -*- import random import subprocess import os BACKGROUND = '/home/david/wallpaper/dell2312' IGNORE_FILES = ['/home/david/wallpaper/dell2312/.direct...
Python ndarray division Question: I have this piece of code from scipy import misc from numpy import fft orig = misc.imread('lena256.png') blur = misc.imread('lena256blur.png') orig_f = fft.rfft2(orig) blur_f = fft.rfft2(blur) kernel_f = blur_f / orig_f # do the ...
Django giving [Errno 13] Permission denied Question: I am developing an application with Python that parses a webpage and then downloads the images contained on the webpage. I am using WAMP for the webserver and DJango for the framework. The python script I have implemented runs as expected (downloads images to my loca...
pythonian comparison: date.time from csv file to date.time from timestamp Question: In python I import a csv file with one datetime value at each row (2013-03-14 07:37:33) and I want to compare it with the datetime values I obtain with timestamp. I assume that when I read the csv the result is strings, but when I try t...