Tagged Questions
Python is a dynamically and strongly typed programming language whose design philosophy emphasizes code readability. Two significantly different versions of Python (2 and 3) are in use. Please mention the version that you are using when asking a question about Python.
0
votes
0answers
4 views
Python operators pymysql
I'm having some bad time with pymysql and python operators.
I don't know much about python operator though.
I want to insert into the database some values. The code:
import pymysql
conn = ...
0
votes
1answer
6 views
post_save signal and relations
I am applying the post_save signal to apply user rights per object, and then filter the queryset accordingly.
My model is like this:
class Project(models.Model):
# Relations with other entities.
...
0
votes
0answers
6 views
What is best way to prevent python requests module blocking indefinitely after computer come back from suspend mode?
Try to do this:
import requests
response = requests.get(some_url)
In some_url variable, assign some url to download a file, for example. While downloading, force your computer to suspend. Finally, ...
0
votes
2answers
39 views
how to fix zero divide error in python?
import os
import re
import sys
sys.stdout=open('f1.txt','w')
from collections import Counter
from glob import glob
def removegarbage(text):
text=re.sub(r'\W+',' ',text)
text=text.lower()
...
0
votes
0answers
2 views
How to convert plot in gtk canvas from pyplot to pixbuf in python?
I'm plotting something using matplotlib in python and want to show the plot in GTK. I'm following this tutorial. The problem is I want to embedded the plot in textview. So I want to convert it to ...
0
votes
0answers
2 views
Sibling processes waiting for slow child process during multiprocess imap. How to avoid?
I am using the imap_unordered function from the multiprocessing module in Python to batch process a significant amount data in parallel. Often this keeps all the assigned processors busy, however, as ...
0
votes
1answer
11 views
Search XML webpage for string
I'm trying to search the following XML code for the id="1140" and return the child objects after the id. Below is a sample of the XML document
<?xml version="1.0" encoding="utf-8"?>
...
1
vote
1answer
28 views
How to strip letters out of a string and compare values?
I have just learned Python for this project I am working on and I am having trouble comparing two values - I am using the Python xlwt and xlrd libraries and pulling values of cells from the documents. ...
-1
votes
0answers
6 views
Explicitly setting the name of tar generated by python setup.py sdist
Is there some way by which we can set the name of tar to something I want generated by running the command
python setup.py sdist
Note : The name of the tar generated is a result of name in ...
0
votes
0answers
4 views
scrapy scrape extra field in linked page
I am trying to scrape some posts on the primary page where almost everything i need is there. But on the link(ed) page there is a date field i additionally need. I tried a callback with the following:
...
0
votes
0answers
18 views
executing django query in same statement
This might be a silly question. Is there a way to execute multiple queries in one execute statement?
cursor = conn.cursor()
cursor.execute("Select * from my_tables; show tables;")
result = ...
0
votes
1answer
8 views
How to iterate through dictionary passed from Python/Tornado handler to Tornado's template?
How to iterate through dictionary passed from Python/Tornado handler to Tornado's template ?
I tried like
<div id="statistics-table">
{% for key, value in statistics %}
...
0
votes
1answer
10 views
Python memcached?
i've been working with php for a while now and have found the memcached library for php.
Now i have a search engine in python and i want to cache content from databases written for python ...
1
vote
3answers
62 views
PYTHON - reading single row from a file
I'm hours new to python, and I'm trying to write a script which reads a set of x,y coordinates from a file (named 'peaks.dat') and fills them into a list (of class type); I'm defining the following:
...
0
votes
1answer
18 views
Pythonic way to find the file with a given name closest to a specific directory location
I'm currently in a project where I'm essentially trying to create a tree structure based on a number of scattered xml files that are, sadly, not very consistently organized. Specifically the point I'm ...