text stringlengths 226 34.5k |
|---|
Python3 submodules setup does not update paths when run with -m switch
Question: I have the following project structure:
server/
server.py
__init__.py
sockets/
module.py
__init__.py
I set `PYTHONPATH` to one directory above server (for example
`/home/us... |
Upgrade to django 1.7 - instance becomes unicode
Question: I recently moved from django 1.2.5 to 1.7.0 (A long overdue upgrade) and as
expected alot of things broke. I have been able to fix alot of things however
I am having one major issue.
I have pickled objects stored in the database. In django 1.2.5, I ran the
bel... |
Random Password Generator Keeps Generating the Same Password
Question: I have to write a program that generates random passwords (using ASCII values
and the chr() function) using Python and I have gotten my program to generate
a random password, but when the program loops, it keeps printing the same
random password and... |
Error while executing python code
Question:
# -*- coding: utf-8 -*-
# coding: utf-8
import sys
import os
import time
b = 'sudo tshark -i eth0 -R “tcp contains “attack”” -T fields -e ip.src -a duration:60>output.txt'
a = os.popen(b)
time.sleep(32)
f = op... |
Comparing 2 excel files via Python. Is there any other recommended language to use instead of python?
Question: reference file:

fill_in:
basically, the you're taking the values in col 1 (left) and comparing them
with the values in the reference f... |
How to get the xpath for jobpage?
Question: I have tried too many possibilities to get xpath for click the "Search Jobs
Now" and "Search " button for to get job list page. but its not find exactly
what i am expected.
Please let me know how to find click the "Search Jobs Now" and "Search" button
and get the joblist pag... |
how to efficiently traverse a directory and get the sha256 checksum for each file
Question: I want to traverse any directory and been available to calculate the
[checkusum](http://en.wikipedia.org/wiki/Checksum) of each file, currently I
am using [python
multiprocessing](https://docs.python.org/2/library/multiprocessin... |
How to loop over a response element in Scrapy?
Question: I am trying to code a scraper with Scrapy for Python. At this point, I am
trying to get the name of the webpage and all the outbound links within the
page. The output should be a dictionary like this
{'link': [u'Link1'], 'title': [u'Page ti... |
Efficiently keeping track of changes in text
Question: I have to send some text over the network to another computer in python. I'll
probably do this using sockets. I'm doing this so people on two different
computers can edit a document at the same time. I was wondering whether there
was an efficient way I could do thi... |
How to continuously updating the display in two different place in Python
Question: I know how to print one line in same plase but I want to print same place from
thread only.
Now I'm getting:
>
> OK 97035
>
I want to get:
>
> OK 97035
> OK 92035
>
First line is from t1 thread, second from t2 threa... |
Python: nested list output
Question: I am reading data from a text file like this
>VAL1;Date1;K123 K135;A lot of text
>VAL2;Date2;K231 K389;more text
>VAL3;Date3;K123;even more text
>VAL4;Date4;K389;even more text
>VAL5;Date5;K634 K123 K888;even more text
Desired output wh... |
Send input to program opened with subprocess using python?
Question: I have the following python code and just want to send a command to the
terminal when it asks a particular question. Here is what I have so far
import subprocess
import sys
cmd = "Some application"
dat = str("")
p =... |
Lambda parameter function in python
Question: I am supposed to analyze shakespeare text using NLTK ( sentiment analysis)
using python 3.4. But I get this error message:
**Traceback (most recent call last):
File "C:\Users\HAMIMOUNE\AppData\Roaming\nltk_data\shakespeare.py", line 8, in <module>
... |
how to import nested module from nested module
Question: Simple question, but could not find the answer. I've following structure:
./lib1:
main.py
./lib2:
__init__.py utils.py
From the root diretory, I'm running:
python lib1/main.py
and in main.py I want to im... |
Python csv to list TypeError: cannot perform reduce with flexible type
Question: I am trying to get my test.csv file that looks like this:
hr,mime,active
100,0.41,1
101,0.19,1
102,0.18,1
103,0.6,1
104,0.45,1
105,0.7,1
90,0.4,1
72.43,0.17,1
73,0.17,1
110,0.5,1
120,1,1
130,2,1
72.19,0.5,1
72... |
Python efficiency for list comparison on numbers >= 10,000
Question: I've been trying to complete a problem from one of the most recent ACM
programming challenges post competition, and have been running into a snag.
The problem states
> Your team has been retained by the director of a competition who supervises
> a pa... |
Trying to add max key to dictionary in another dictionary Error
Question: I am trying to add the max key of the first dictionary in a second but when I
run it shows me a syntax error for `sack{}`. And I can't seem to figure out
why this error occurs. Could anyone explain what the error is? Thank you.
The Code is as be... |
Speeding up selecting sets of 3 nodes that form triangles with given min and max side length
Question: I've got a list of about 60 points, from which I'm generating all possible
combinations of size 3. I'm trying to determine whether any of the 3 points
are within certain distance parameters - that is, not too close to... |
Easy way to find what item repeated in list
Question: So I have list like
l = [1,2,3,4,4]
If I make a set obvilously I will get
([1,2,3,4])
I need a way to find what item repeated in list and was popped out and I do
not want to use looping. If there is an easy way to do so? I'... |
Integrating exisiting Python Library to Anaconda
Question: I've been installing few Library/Toolkit for Python like NLTK, SciPy and NumPy
on my Ubuntu. I would like to try to use Anaconda distribution though. Should
I remove my existing libraries before installing Anaconda?
Answer: There is no need to remove your sys... |
Simultaneously using multiple views in the iPython Notebook
Question: I've got a question I'm hoping someone can help me figure out. I'm trying to
construct two different parallel views in an iPython notebook. The first view
has the processor with ID 0, and the second has all the rest of the
processors. I associate a p... |
Django datetime migration error
Question: I don't think anything in my model has changed. I have reverted it back to
times when it was all fully functional and I still get the following errors.
There are my models:
class UserProfile(models.Model):
# This line is required. Links UserProfile to a ... |
Python Include char every x positions
Question: I want to include a char every 2 positions, to be specific, I have a MAC
address this way: 00ffabcafe4c and I want it to be 00:ff:ab:ca:fe:4c
Any idea¿? Thank you in advance
Answer:
import re
x="00ffabcafe4c"
print re.sub(r"(\w{2}(?!$))",r"\1:",x)
Ou... |
Initialization of the kmeans2 in python
Question: I am using `scipy.cluster.vq.kmeans2` which, by definition, initializes the
K-means randomly (given the pre-defined initialization method - random,
points).
Is there a way to make the initialization stable, i.e., for the same initial
centroids to obtain the same cluste... |
How can i use matplotlib's plot-directive with python-3 in ReadTheDocs?
Question: I'm having a **python-3** project that uses the **[plot-
directive](http://matplotlib.org/sampledoc/extensions.html#inserting-
matplotlib-plots)** to generate and embed matplotlib's diagrams on the fly,
and i'm using [ReadTheDocs](https:/... |
Advice on code structure to prevent duplication of code (Python, lists)
Question: The scenario at play is that I have an ordered list of items. I want to
convert that list into a single string.
However.
It's not simply a matter of converting each item into a string and
concatenating. I need to do some processing on t... |
Django/Python Chain and Sort Querysets
Question: I have an inventory count that has N locations, this locations needs to be
counted N times, so I have one model for "the location header" and another for
the item list of every header.
I need to chain,sort AND get unique results of the items in N querysets
I have this:... |
Is deep monkeypatching possible in Python?
Question: Take a look at this [changeset for
Django](https://github.com/django/django/commit/be0ad62994a340ad54a0b328771931932a45a899).
I need this functionality, however this patch comes from Django's 1.7 release,
which I can't use in my environment (Python 2.6 only). So for ... |
How to parse sentences based on lexical content (phrases) with Python-NLTK
Question: Can Python-NLTK recognize input string and parse it not only based on white
space but also on the content? Say, "computer system" became a phrases in this
situation. Can anyone provide a sample code?
* * *
**input String** : "A surve... |
Python XML Parsing can't find children of children
Question: I'm trying to parse XML returned as a string from a http get request. I need
to get a specific link inside the XML structure but for some reason I can't
get to the link I need. I tried `**enumerating**` the XML and printing
**`child.attrib`** but the link I n... |
Is it possible to slice keys in h5py using python 3, without forming a list?
Question: I am using h5py to read in data from an HDF5 file, and have found that code
which worked using Python 2 does not work using Python 3. The file is
formatted such that 2D frames of data are present as distinct datasets, which
I want to... |
Python multithreading "ping"
Question: I have been trying to make a python script that will ask you for a IP and have
many simultaneous PING i shall do.
But it seems like i can only run one PING at a time
I'm running on OSX
import _thread
import os
import time
def main():
... |
Unusual output using map() and filter() in Python
Question: I'm trying to learn how to use the map() and filter() functions in Python but
when I try and use them in visual studio, I'm getting an unusual output for
each one. I know the code is probably wrong, but I can't see what it's
outputting which is making it hard ... |
Universal iteration over all elements of: nested list, numpy array, pandas dataframe
Question: I am trying to write a function that applies to each element of the argument
provided, whether the argument is a nested python list, a numpy array or a
pandas dataframe or series.
Example: (not working)
import... |
How to patch a constant in python
Question: I have two different modules in my project. One is a config file which
contains
LOGGING_ACTIVATED = False
This constant is used in the second module (lets call it main) like the
following:
if LOGGING_ACTIVATED:
amqp_connector = Conn... |
save url as a file name in python
Question: Firstly, I'm pretty new in python, please leave a comment as well if you
consider to down vote
I have a url such as
http://example.com/here/there/index.html
now I want to save a file and its content in a directory. I want the name of
the file to be :
... |
Python unittesting: Test whether two angles are almost equal
Question: I want to test a function that outputs a heading in degrees, which is a number
in the interval [0, 360). Since the result is a floating-point number,
comparing the actual result against the expected with `unittest.assertEqual()`
does not work. `unit... |
Dates ( pi-Day )
Question: I think everyone kwows when it's pi-Day (If you don't know it's on 14 March
each year). When you have a result in python like:
(2016, 4, 4)
(This stands for the April 4, 2016). How can I find in a fast way when it's
the next pi-Day. In this example the answer would be:
... |
Hive with python transform function: "cannot recognize input near 'transform'" error
Question: I have a Hive table that tracks the status of an object moving through stages
of a process. The table looks like this:
hive> desc journeys;
object_id string
... |
replace part of path - python
Question: Is there a quick way to replace part of the path in python?
for example:
old_path='/abc/dfg/ghi/f.txt'
I don't know the beginning of the path (`/abc/dfg/`), so what I'd really like
to tell python to keep everything that comes after `/ghi/` (inclusive) and
re... |
How can I turn off error printing in libxml2.parseDoc?
Question: When using the library, I expect an exception for bad input, but I do not want
it to start printing things to stderr. How can I configure it to not print
anything?
Here's an example from the REPL of what I am talking about:
>>> import libx... |
Why doesn't my idea work in python2?
Question: Here is an idea for a dict subclass that can mutate keys. This is a simple
self contained example that's just like a `dict` but is case insensitive for
`str` keys.
from functools import wraps
def key_fix_decorator(f):
@wraps(f)
def w... |
Migration error with Django 1.7.1
Question: I'm getting an error when performing a migration after introducing a new app
(django-allauth). I'm not sure what else to try in order to fix the error.
I've tried a few things but they don't seem to help unfortunately.
when running **manage.py migrate** :
File... |
Read a list of file names without typing them manually
Question: I have a python code inside which the name of file is received with input
command
fileName = input("please enter the file name")
My purpose is to write a script to run this file. But I do not want to sit
there and input each file name manually. Is it po... |
How to ensure two line breaks between each paragraph in python
Question: I am reading txt files into python, and want to get paragraph breaks
consistent. Sometimes there is one, two, three, four... occasionally several
tens or hundreds of blank lines between paragraphs.
It is obviously easy to strip out all the breaks... |
from pygtk_image import * ERROR
Question: I am new to python and I have question, please. I have python 2.7.3 and I have
installed gtk to make GUI. I found a code and I want to test it but I got this
error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from pygtk_... |
How to make 1d array multiplied by 2d array resulting in 3d array for python
Question: I am worrying that this might be a really stupid question. However I can't
find a solution. I want to do the following operation in python without using
a loop, because I am dealing with large size arrays. Is there any suggestion?
... |
Reading changes with dbf library in python
Question: I am trying to make a program that takes changes in a `dbf` file then uploads
them. I have got it to read the `dbf` file and upload them to a `mysql`
database but its a 50 minuite upload. I have tried to get it to only upload
fields that have been changed. The proble... |
Trying to use docutils.parsers.rst.tableparser in Python
Question: I would like to use the parser in the Python docutils.parsers.rst.tableparser
package to grab a plaintext table and parse it easily. The format of the
tables tableparser can read is very convinient for my project.
The problem is that, even though the d... |
most frequent words in a french text
Question: I am using the python `nltk` package to find the most frequent words in a
French text. I find it not really working... Here is my code:
#-*- coding: utf-8 -*-
#nltk: package for text analysis
from nltk.probability import FreqDist
from nltk.c... |
Upload a recording to Google App Engine from Android app
Question: I have created an android app that does basic voice recordings (stored as
.mp4). I want to add a feature where I can send a recording (just one at a
time, no batches needed) to Google App Engine cloud storage. Then, I want to
be able to listen to these ... |
Python Subprocess Behavior with Eclipse
Question: I am trying to run Eclipse from the command line to automate some project
importing and i am having an issue with pythons subprocess. Subprocess seems
to be ignoring my command arguments and just running eclipse straight up.
Here is what i am trying to do:
... |
Python 2.7 Tkinter - Multiple window entry update
Question: I would like the text to appear and be updated in each window, instead of only
in one. I have noticed that the window that works is always the first that is
being called, but that does not help me solve the issue.
Another thing I noticed is that the program a... |
String building with regex
Question: So I am fairly new to python and am only self taught in this particular
language, but I have hit a bit of a snag.
What I am trying to do is build a string that has with in it a digit that can
be of any length or pattern. For example:
"Data_image_%s.%d" %(myStr, r'... |
ctype - python - long int too long to convert -
Question: problem:
> Traceback (most recent call last): File "C:\Users\Nutzer\Google
> Drive\Code\Code\memory_read.py", line 26, in byref(bytesRead))
> ctypes.ArgumentError: argument 2: : **long int too long to convert**
code:
from ctypes import *
fro... |
Elasticsearch TransportError(400, u'MapperParsingException
Question: I have run the following python code with no errors. But now I am having this
TransportError(400, u'MapperParsingException [Analyzer [whitespace_analyzer] not found for field [job style]]'
The code is :
from elastic... |
SQL query in Python gives OperationalError: near "WITH": syntax error
Question: I've been trying to do some CSV file merging using SQL in Python with SQL
query being the following:
WITH
MATCHES AS( -- get all matches
SELECT CSV2.*
, CSV1.ROW as ROW_1
... |
Python cmd on linux does not autocomplete special characters or symbols
Question: Characters such as `-` , `+` etc are not parsed the same way as alphanumeric
ASCII characters by Python's readline based cmd module. This seems to be linux
specific issue only, as it seems to work as expected on Mac OS.
**Sample code**
... |
Functions defined in dynamically-loaded scripts cannot refer to each other
Question: I'm trying to load functions from a script dynamically when I'm inside an
ipython interactive shell. For example, suppose I have a python script like
this:
# script.py
import IPython as ip
def Reload():
... |
Testing programs that read form sys.stdin
Question: I am playing with some programming challenges that will check the submission
by:
python my_submission < in.txt > out.txt
When I try and make my submission, I want to read some cases/numbers/whatever
from _in.txt_ to see what is happening. Currentl... |
graph in python from a list of edges
Question: I have a list of edges in a text file:
0 1
0 2
0 3
1 637
1 754
1 1319
1 1350
1 1463
1 1523
2 637
2 754
2 1319
2 1350
2 1463
2 1523
3 499
3 539
3 595
3 637
3 706
3 1128
3 119... |
Search elements in an array of arrays
Question: Sorry if I get terminology wrong - I've only just started learning Python, and
I'm receiving instruction from friends instead of being on an actual course.
I want to search a list containing lots of arrays containing multiple
elements, and find arrays with some elements ... |
Tkinter button not working (Python 3.x)
Question: I'm working on my final project for my computing I class.
The problem that I am having is:
When I click on the new entry button, hit the back button and click on the new
entry button once again it **does not work**.
If you guys could tell me why that is?
The comman... |
can't get correct python regex with this string that contains unicode
Question: I have this string:
s = u'vitamin a min. 14,053 iu/kg vitamin c 13,000iu/kg vitamin d max. 10,000\u03bc/kg copper 1mg/kg vitamin e mon 10.00iu/kg'
I want to break it apart so I get `[label, label2, amount, units]`.
... |
Django - passing a variable from a view into a url tag in template
Question: First of all, I apologize for the noobish question. I'm very new to Django and
I'm sure I'm missing something obvious. I have read many other posts here and
have not been able to find whatever obvious thing I am doing wrong. Thanks so
much for... |
Why is module global assignment different simple types vs classes/dictionaries?
Question: Given the following example code:
test.py
import module
print 'main: Vars.foo: %s' % (module.Vars.foo)
print 'main: d.foo: %s' % (module.d['foo'])
print 'main: foo: %s' % (module.foo)
print
... |
Twill doesn't show forms
Question: I'm trying to login in <https://accounts.coursera.org/> using twill for python
I tried this sheet of code
import twill
b = get_browser()
b.go("https://accounts.coursera.org/")
b.showforms()
twill doesn't detect the form in the page and showforms m... |
Why is PIP not upgrading the Package
Question: Why is `pip` not installing the LATEST? Is there a way to force LATEST?
$ sudo pip install --upgrade pefile
Requirement already up-to-date: pefile in /usr/local/lib/python2.7/dist-packages
Cleaning up...
$ pip show pefile
---
Name: p... |
Eucalyptus Walrus/Amazon S3 SOAP signature is failing
Question: I have been learning how to use Amazon S3 API by using the open source
Eucalyptus. So far I have been able to successfully use REST, but now I would
also like to use SOAP. I seem to be having trouble generating the correct
signature for my request. The ser... |
Python SQLite ToDo script
Question: I'm trying to make a script that asks the user to input a task, the task is
then stored in a SQLite database. I am having a problem getting my delete
function to work. Also when I input a new task I have to encapsulate in quotes
in order to make it run.
import sqlite3
... |
Using raw_input in python for lists
Question: I am trying to use raw_input in the python code to get user input of lists as
below.
input_array.append(list(raw_input()));
User input as:
1 2 3 5 100
But the code is interpreting input as
[['1', ' ', '2', ' ', '3', '... |
VIM/Python cannot return value to VIM
Question: I'm trying to create a Python plugin for VIM that will detect whether or not
the current project is an Android Project. Unfortunately, I cannot get it to
return boolean values back to VIM. Calling the plugin from within VIM just
outputs nothing. The code below uses the `p... |
why argument of type 'NoneType' is not iterable is shown in my program
Question: i made this hangman program but it is giving 'nonetype' error whenever i run
it program running- Whenever I enter a word the output is like this Hang Man
Game Guess a word a \----- You gussed one word correctly
-----a------... |
Why can I pass an instance method to multiprocessing.Process, but not a multiprocessing.Pool?
Question: I am trying to write an application that applies a function concurrently with
a `multiprocessing.Pool`. I would like this function to be an instance method
(so I can define it differently in different subclasses). Th... |
appending a list from a read text file python3
Question: I am attempting to read a txt file and create a dictionary from the text. a
sample txt file is:
John likes Steak
John likes Soda
John likes Cake
Jane likes Soda
Jane likes Cake
Jim likes Steak
My d... |
read in one row of csv file (based on input if i can) with DictReader, then format and write to new file
Question: I'm trying to read in a csv file with many rows and columns; i would like to
print one row, in a particular format, to a text file, and do some hashing on
the values. SO far, i have been able to read in th... |
Solving constrained maximization with SciPy
Question: Function to maximize:
x[0] + x[1] + x[2]
Constraints:
0.2 * x[0] + 0.4 * x[1] - 0.33 * x[2] <= 25
5 * x[0] + 8.33 * x[2] <= 130
...
x[0] >= 0
x[1] >= 0
x[2] >= 0
My code looks like:
from nu... |
How do I correctly pass double quotes to an awk subprocess in Python?
Question: I am trying to run simple awk shell command and capture its output (using
python2). Here is what I try to do:
import subprocess as sb
shell = ["awk '!/<tag>/ {print \"\\"\"$1\"\\"\", \"\\"\"$2\"\\"\"}' test.txt"]
... |
Python 3.4 - Connect to imap server using only TLSv1
Question: I'm trying to connect to an imap mail server using only TLSv1 in Python 3.4.
After much troubleshooting (most of which determined that the mail server only
supports TLSv1), I've found that I can connect to the server using openssl:
openssl s... |
Python, yahoo yql quote error
Question: I have used the yql Console and have received an appropriate response.
However, sending a python based query, I continue to have an error. First the
console example:
select * from yahoo.finance.quotes where symbol in ("yahoo", "aapl")
I receive a results bloc... |
How to write output of web scrape to column instead of rows in Beautiful Soup
Question: I'm trying to write the results of scraping a webpage to a CSV file. I have
successfully written the output to CSV but it went in as rows instead of
columns. Here is the script:
import bs4
import requests
impo... |
Simple Guess My Number Game in Python - invalid syntax
Question: I try to make a simple guessing game with the "Python programming for absolute
beginner" book. Game should generate random number from 0 to 10, then take
player's guesses and print "Too high!", if the guessed number is too high, or
"Too low!" if the numbe... |
Using Python to Access Methods From C# Library - Interop .dll File
Question: I have a .dll file (with "Interop." prefix) containing a library written in
C#. Within the library is a class, several enums, several interfaces, and
several delgates. (Observed by decompiling the .dll with JetBrains dotPeek)
See the dll stru... |
HTMLParser for Python 3.4
Question: I have some code written in Python(2.7) which uses HTMLParser. I am using
Pyhton 3.4 currently.
I can not find HTMLParse download module. I have searched a lot. I cannot find
it.
I am concerned if it even exists. If it exists, please share the link. If not,
what should I do?
Answ... |
TypeError: object() takes no parameters - making games
Question: I'm quite new to Python programming and just picked it up about a week ago. I
wrote (significantly altered) a game based on a pre-existing code and ran the
code and got an error message. So I went back to the original code that's
supposed to be working an... |
Creating a window with an unknown amount of checkboxes - Python/tkinter
Question: I'm working on a project for my computer science class involving python and
tkinter. I'm trying to make a fully-functional Monopoly game, and it's coming
along well. I've finally hit one roadblock that I can't seem to overcome. I'm
trying... |
How to send an email in python?
Question: I would like to send an email in Python. Below an example code:
#!/usr/bin/python
import smtplib
sender = 'test@gmail.com'
receivers = ['test@gmail.com']
message = """From: From Person <from@fromdomain.com>
To: To Person <to@tod... |
Remove or keep specific columns in csv file
Question: I have a simple script to either remove last n columns from csv file or to
keep first n columns only in csv file:
from sys import argv
import csv
if len(argv) == 4:
script, inputFile, outputFile, n = argv
n = [int(i) for i in ... |
Error importing module from package, package itself imported but empty, pip says package installed and up-to-date
Question: I have anaconda python 2.7 and installed the shapely package. Importing the
whole package does not give errors, but then when trying to access modules
that should be loaded, they dont seem to be t... |
how to find all the index of an element in a list Python
Question: If I have a list
a=[1,0,0,1,0,1,1,1,0,1,0,0]
I want to find the index of 0 and 1 respectively, say in this case,
index_0 = [1,2,4,8,10,11]
index_1 = [0,3,5,6,7,9]
is there an efficient way to do this?
Answ... |
Python Merge 2 or more Dicts using a value to handle duplicate keys
Question: I am merging dictionaries that have some duplicate keys. The values will be
different and I want to ignore the lower value record.
dict1 = {1 :["in",1], 2 :["out",1], 3 :["in",1]}
dict2 = {1 :["out",2], 2 :["out",1]}
... |
Python Boolean in Brackets?
Question: I'm working on OpenCV using python, and in the edge detection script
[here](https://code.google.com/p/pythonxy/source/browse/src/python/OpenCV/DOC/samples/python2/edge.py?repo=xy-27&r=a2e41c7a3cb6db536b948747872cab71c696b44e)
I've encountered something I've never seen before. I apo... |
How can I use pyglet batches to draw scenes or levels
Question: So I'm currently learning pyglet for Python 2.7 and I'm trying to make a
simple game that has levels. The 1st 'scene' would be the title/intro part,
2nd would be a tutorial of some sort, and the rest are the game levels
themselves.
For this, I've created ... |
IOLoop.add_handler won't accept certain file descriptors
Question: Python tornado's `IOLoop.add_handler(fd,handler,events)` says "the fd argument
may either be an integer file descriptor or a file-like object with a fileno()
method", and as of 4.0, it "Added the ability to pass file-like objects in
addition to raw file... |
Python urllib2.urlopen returns a HTTP error 503
Question: Here you can see my code snippet. Since 3 days it does not work any longer. My
python is running under Ubuntu 10.04.4 LTS. Python version is 2.6.5.
#!/usr/bin/env python
import urllib2 as ur
...
webpage = []
site = "http://www... |
Proper way to destroy a file chooser dialog in pygtk for python
Question: I've been trying to use gtk to create a folder choosing dialog, but I can't
figure out how to make the dialog close. Here is the code:
from gi.repository import Gtk
import time
dialog = Gtk.FileChooserDialog("Please ch... |
Error in import FloatField, using django-import-export
Question: I am using django-import-export for import csv file. I have a `FloatField` in
my model :
**models.py**
purchase_price = models.FloatField(null=True, blank=True)
When I import csv file with blank value, it throws an error :
**ValueEr... |
Why inheriting from namedtuple results in infinite recursion in this case?
Question: I planned to write a small class to host a dictionary of stuff and some helper
methods related to it. While in this particular case inheriting from
`namedtuple` doesn't make much sense, I did it out of habit.
class Conf(... |
python unittest with coverage report on (sub)processes
Question: I'm using `nose` to run my "unittest" tests and have `nose-cov` to include
coverage reports. These all work fine, but part of my tests require running
some code as a `multiprocessing.Process`. The `nose-cov` docs state that it
can do `multiprocessing`, bu... |
Python dictionary / database in memory
Question: I have a file that looks like this:
LastName FirstName Age Gender Height Weight
Smith May 20 F 1500 55
Wilder Harry 25 M 1800 65
Potter Harry 50 M 1600 66
Lincoln Abram 100 M 1800 55
Reynolds M... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.