Questions for python


python: how to import * and call imported functions when package is directory not file

if I'm developing a client-server app and have 3 files,, and, and has a useful function "normalize()", it's easy from both client and server to "from common ...

How to know if python script was run using interpreter's -m option?

I couldn't find answer after having read all the following:

Single precision big endian float values to Python's float (double precision, big endian)

I need to receive hex encoded single precision big endian float values coming from an Arduino over a serial line (RS-232). How do convert them to Python's float which are big endians with double

Trouble setting Python version in Sublime Text2

I'm having trouble setting the build environment in Sublime Text2.

Newly added record in datastore is not refelcting in the application

I have been facing this problem in app engine. As I am new to App Engine, I don't know whether I am doing it right way or not.

how to add/subtract 2 days in the target day in python?

I have a problem in adding or subtracting 2 days to the target day...

three argument filtering

Lets assume I have defined function:

Python Login Script

I know similar questions have been asked, I have read them. I have also read most other related articles I could find. I have tried httplib2, header modifications, and anything else I could find or...

MX Record lookup and check

I need to create a tool that will check a domains live mx records against what should be expected (we have had issues with some of our staff fiddling with them and causing all incoming mail to redi...

Passing a variable to a method in a class

I'm new to using classes and I'm trying to pass a variable to one of the methods inside of my class. How do I do it?

Scraping multiple pages for parsing in Beautiful Soup

I'm trying to scrape multiple pages off of a single website for BeautifulSoup to parse. So far, I've tried using urllib2 to do this, but have been encountering some problems. What I've attempted is:

pip giving “ImportError: No module named setuptools” but I can import setuptools in python interpreter

I'm getting setup on a new mac and I was humming along just fine, installing pip and a few packages. When suddenly, every pip command I'd try to run would throw

Problem with Arduino and pySerial

I got a problem. I recently bought an Arduino Uno board. I tried to make something funny like controlling an input from my computer. I used Python with pySerial and the program is the following:

Decoding unicode from Javascript in Python & Django

On a website I have the word pluČ™ sent via POST to a Django view.

python USER_BASE error

I am using python 2.6 and trying to install django tagging package and i get this error below.I am installing few python 2.4 packages on a 64 bit machine which already has python2.6.

Test computer processing speed with a simple Python script

I want to make a simple script just to test the time that the computer takes to execute it.

Count frequency of letters in a text file

In python, how can I iterate through a text file and count the number of occurrences of each letter? I realise I could just use a 'for x in file' statement to go through it and then set up 26 or so...

Jinja 2 safe keyword

I have a little problem understanding what an expression like {{ something.render() | safe }} does .

Storing items in a DynamoDB table where the key and range key may overlap

I'm looking to store a large collection of photos in a DynamoDB table.

Is it possible to set the implicit OneToOne key directly when using multi table inheritance in Django?

I'm trying to extend a library model through multi-table inheritance and this is what I ended up with:

Django + fcgi = new edits to not shown

I wanted to dive into Python\Django development and used what I had at hands:

Windows opens .py file with C:\Python27\Python.exe despite rebinding Python.File

I followed Python's official FAQ to make .py file executable, i.e. adding .py to $PATHEXT and bind Python.File to "C:\Python27\Python.exe" "%1" %*. The result was fine:

Random Forest interpretation in scikit-learn

I am using scikit-learn's Random Forest Regressor to fit a random forest regressor on a dataset. Is it possible to interpret the output in a format where I can then implement the model fit without ...

python module import question

So I have a big project with many modules in it, and I want to run some profiling on it. I have a profile module that basically just provides a decorator that I can add to a function to profile it ...

How to get started with Big Data Analysis

I've been a long time user of R and have recently started working with Python. Using conventional RDBMS systems for data warehousing, and R/Python for number-crunching, I feel the need now to get my

How do I catch/except registration errors with Django?

I want to be able to return a message to the user when they try to register but their registration fails.

predict the outcome numbers using a list

I have 3 lists with 3 sets of integers. I want to predict the outcome numbers using a list or by whatever other means is out there.

Edgelines vanish in mplot3d surf when facecolors are specified

I have produced the following surface plot in matlab:

Setting up Python and Virtualenv on OS X 10.8.1?

I recently reinstalled my OS X and my python setup is gone with it. I can't remember how I set it up before and now I am having a lot of trouble. I followed this guide

How do I do a case insensitive string comparison in Python?

What's the best way to do case insensitive string comparison in Python?

Add sub-elements to newly created elements in python elementtree

I am trying to add the following subtree to an element 'Drugs' in an xml file using elementtree in Python based on the data in CSV file:

ElementTree and unicode

I have this char in an xml file:

String format a json String gives KeyError

Why does this code give a KeyError?

Python - Backslash Quoting in String Literals

I have a string that contains both double-quotes and backslashes that I want to set to a variable in Python. However, whenever I try to set it, the quotes or slashes are either removed or escaped. ...

Cleaning Python modules an have fresh start Mac OS X

I am not a total newbie but I am trying to install modules for quite a long time and at this point i would like to have a fresh start and install python and all the modules I need so i really under...

Python dictionary keys besides strings and integers?

Anyone have some neat examples of dictionaries with some interesting keys (besides the canonical string or integer), and how you used these in your program?

Python 2.7, OS portable way to determine permissions / contents of a puser entered path

Disclaimer: i have searched genericly (Google) and here for some information on this topic, but most of the answers are either very old, or don't seem to quite make sense to me, so I appologize in

Tkinter Display varLabel and value cleanly

I've am new to Tkinter and have written a program to open a file and parse binary messages.

Passing List Values as Parameters

list = ['12345','23456']

What do I use on linux to make a python program executable

I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.

Python - get UTC offset by seconds

Based on this code, how do I get the UTC offset of a given date by seconds. get UTC offset from time zone name in python

Fast cross correlation method in Python

I have been recently trying to find a fast and efficient way to perform cross correlation check between two arrays using Python language. After some reading, I found these two options:

Packaging a Python library

I have a few Munin plugins which report stats from an Autonomy database. They all use a small library which scrapes the XML status output for the relevant numbers.

How do I make PIL take into account the shortest side when creating a thumbnail?

Currently, for my function below...the image will be resized based on the longest side.

how do django forms work

I am learning Django. Particularly I am reading about forms and I cannot understand how do they work.

Matplotlib histograms (basic questions)

I am trying to plot a simple histogram using matplotlib. I have for example (I will in practice be using different distance functions)

Combine all elements of two arrays python

I have two arrays, and want to combine the ith elements in each one together:

Read a file, skip unwanted lines & add into a List

I have the following code where I scan every line and put in a list. If the line matches