How to print to stderr in Python?

Python
I've come across at least three ways to print to stderr: import sys print >> sys.stderr, 'spam' sys.stderr.write('spam\n') from __future...
3 years ago

Python unicode string literals in module declared as utf-8

Python
I have a dummie Python module with the utf-8 header that looks like this: # -*- coding: utf-8 -*- a = "รก" print type(a), a Which prints: <type ...
3 years ago

Can't get my function to do anything

Python
Working on a program that "encrypts" and "decrypts" an input string, no matter how I arrange my returns or function calls. I feel like something is st...
3 years ago

No schema supplied and other errors with using requests.get()

Python
I'm learning Python by following Automate the Boring Stuff. This program is supposed to go to http://xkcd.com/ and download all the images for offline...
3 years ago

save values in database using django

Python
i have an custom form , whenever i fetch the form values to save in the database than it display an error ( applicationform() got an unexpected keywor...
3 years ago

Refresh Browser tab in the background (Python script)

Python
This may not be the right platform to ask to ask this question. I was looking for an application that refreshes a particular tab in the browser so t...
3 years ago

Finding the most common pair, trio, etc. in a list of 20 random numbers, played 100 times

Python
So I have a CSV with 100 rows, 20 numbers on each row separated with a comma as such: 23, 52, 63, 76, 23, 45, ... 39, 52, 83, 33, 35, 23, ... etc. ...
3 years ago

Project Euler 5 in Python - How can I optimize my solution?

Python
I've recently been working on Project Euler problems in Python. I am fairly new to Python, and still somewhat new as a programmer. In any case, I've...
3 years ago

Django upload and process file with no data retention

Python
Python: 2.7.11 Django: 1.9 I want to upload a csv file to Django and analyze it with a Python class. No saving is allowed and the file is only neede...
3 years ago

Python - Write Header Once - Loop isn't working properly

Python
I am trying to write an "order file" with a Header and Detail Lines. I am successfully getting the order Header to write to file, but only one detail...
3 years ago

Mark ticks in latex in matplotlib

Python
In a plot in matplotlib I specially want to mark points on the x-axis as pi/2, pi, 3pi/2 and so on in latex. How can I do it?
3 years ago

Django Queryset for substr matching that starts from the beginning of a string

Python
I have model Word, where every instance of the model stores a word or phrase in a field called text. e.g., "matches" "match" "match sticks" "matching"...
3 years ago

How to send an email with Python?

Python
This code works and sends me an email just fine: import smtplib #SERVER = "localhost" FROM = 'monty@python.com' TO = ["jon@mycompany.com"] # must...
3 years ago

Round up numbers such as 1.23 to 2 in Python

Python
Please tell me how to round up numbers in Python. If I have 1.47, how to round it up to 2 ? Or if I have 10.13, how to round it up to 11? The answe...
3 years ago

Python -- Add key/values to dictionary using condition

Python
I have a list of items that I'm adding to dictionary below: COLS = ['CUST', 'MODEL', 'SN', 'DATE', 'CHARGE', 'QTY', 'TOTAL'] with open('UserfeeInvoic...
3 years ago

sharing a :memory: database between different threads in python using sqlite3 package

Python
I would like to create a :memory: database in python and access it from different threads. Essentially something like: class T(threading.Thread): ...
3 years ago

python pandas: reverse df column order

Python
I want to simply reverse the column order of a given df. my df data = {'year': [2010, 2011, 2012, 2011, 2012, 2010, 2011, 2012], 'team': ['Bea...
3 years ago

Getting AttributeError on nltk Textual entailment classifier

Python
Im referring to the link in the section http://www.nltk.org/book/ch06.html#recognizing-textual-entailment def rte_features(rtepair): extractor = ...
3 years ago

How to skip a section in config file using configparser

Python
I have written a code where parameters are taken from a config file. My first parameter in the config is for setting the debug level. config = Co...
3 years ago

Location of contour lines

Python
Below is my code and plot: import matplotlib import matplotlib.mlab as mlab import matplotlib.cm as cm import matplotlib.pyplot as plt import numpy a...
3 years ago