python

Are many Dojo Toolkit users also using Python?

I've coming to be more interested in Dojo Toolkit which I find great, but are many Dojo users also using Python also? And why is it like that? I heard of Cherry Py (and why not Django?). ...

BeautifulSoup: just get inside of a tag, no matter how many enclosing tags there are

I'm trying to scrape all the inner html from the <p> elements in a web page using BeautifulSoup. There are internal tags, but I don't care, I just want to get the internal text. For example, for: <p>Red</p> <p><i>Blue</i></p> <p>Yellow</p> <p>Light <b>green</b></p> How can I extract: Red Blue Yellow Light green Neither .string nor...

Make 2 functions run at the same time.

Hi, I am trying to make 2 functions run at the same time. def func1(): print 'Working' def func2(): print 'Working' func1() func2() Does anyone know how to do this? ...

Decompose a Python string into its characters

I want to break a Python string into its characters. sequenceOfAlphabets = list( string.uppercase ) works. However, why does not sequenceOfAlphabets = re.split( '.', string.uppercase ) work? All I get are empty, albeit expected count of elements ...

Best, free, online Python tutorials and references for an experienced programmer?

I have been doing Java, and C# for many years. Starting on my first big Python program now. I have written a few, very small, text processing scripts in Python years ago. I would like to know what is the best, free, online Python tutorial for experienced programmers. Python in general, but then also web programming with Python. Will be ...

running a python script on a remote computer

Hello all, I have a python script and am wondering is there any way that I can ensure that the script run's continuously on a remote computer? Like for example, if the script crashes for whatever reason, is there a way to start it up automatically instead of having to remote desktop. Are there any other factors I have to be aware of? The...

Creating a tiled map with blender

I'm looking at creating map tiles based on a 3D model made in blender, The map is 16 x 16 in blender. I've got 4 different zoom levels and each tile is 100 x 100 pixels. The entire map at the most zoomed out level is 4 x 4 tiles constructing an image of 400 x 400. The most zoomed in level is 256 x 256 obviously constructing an image ...

Python - alternative to list.remove(x)?

Hi, I wish to compare two lists. Generally this is not a problem as I usually use a nested for loop and append the intersection to a new list. In this case, I need to delete the intersection of A and B from A. A = [['ab', 'cd', 'ef', '0', '567'], ['ghy5'], ['pop', 'eye']] B = [['ab'], ['hi'], ['op'], ['ej']] My objective is to com...

Crossed import in django

On example, i have 2 apps: alpha and beta in alpha/models.py import of model from beta.models and in beta/models.py import of model from alpha.models manage.py validate says that ImportError: cannot import name ModelName how to solve this problem? ...

What are the advantages or difference in “assert False” and “self.assertFalse”

Hello, I am wrting test's and I have heard some people saying to use self.assertFalse rather than assert False. Why is this and are there any advantages to be had? Thanks ...

Python script names in tasklist

I am wondering, is there a way to change the name of a script so that it is not called "python.exe" in the tasklist. The reason I am asking is that I am trying to make a batch file that run's a python script. I want the batch file to check to see if the script is already running. if the script is already running then the batch file will ...

Determine site domain in BaseHTTPServer

I try to implement simple server on python based on HTTPServer. How can i extract information about site domain served in current request? I mean it can serv several domains such as site1.com and site2.com for example, how can i get it in this code: from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class MyHandler(BaseHTTPR...

PyEphem (sunrise / sunset time calculation) equivalent in C#

PyEphem is a neat library that allows easy calculation of sunrise, set, dawn, and dusk of location based on lat, long, and UTC timestamp I don't want to go through the calculation myself, rather I was wondering if there is an existing library I could use ...

Python division

Can somebody explain this to me? I was trying to normalize a set of numbers from -100 to 0 to a range of 10-100 and was having problems only to notice that even with no variables at all, this does not evaluate the way I would expect it to: >>> (20-10) / (100-10) 0 EDIT: float division doesn't work either: >>> float((20-10) / (100-10...

Python - a clean approach to this problem?

Hi, I am having trouble picking the best data structure for solving a problem. The problem is as below: I have a nested list of identity codes where the sublists are of varying length. li = [['abc', 'ghi', 'lmn'], ['kop'], ['hgi', 'ghy']] I have a file with two entries on each line; an identity code and a number. abc 2.93 g...

Python: Mat-File into hex-values

filename = r"C:\Dokumente und Einstellungen\sschnei1\Desktop\a.mat" print open(filename, "r").read().encode("hex") The code above only work for text files. But I want to read out the hex-values of mat-files. EDIT: my little hex-editor from textwrap import fill filename = r"C:\a.mat" hexvalues = open(filename, "rb").read().encode("hex...

importing symbols from python package into caller's namespace

I have a little internal DSL written in a single Python file that has grown to a point where I would like to split the contents across a number of different directories + files. The new directory structure currently looks like this: dsl/ __init__.py types/ __init__.py type1.py type2.py and each type fi...

Find&Replace using Python - Binary file

Hello, I'm attempting to do a "find and replace" in a file on a Mac OS X computer. Although it appears to work correctly. It seems that the file is somehow altered. The text editor that I use (Text Wrangler) is unable to even open the file once this is completed. Here is the code as I have it: import fileinput for line in fileinp...

Making a python script only be able to run once at a time

I am looking to make a python script be unique in the sense that it can only run once at a time. For example if I run the script and open another session of the same script a second time and the first session is still running, then the second session will just exit and do nothing. Anyone knows how I could implement this? ...

Best practice: How to persist simple data without a database in django?

I'm building a website that doesn't require a database because a REST API "is the database". (Except you don't want to be putting site-specific things in there, since the API is used by mostly mobile clients) However there's a few things that normally would be put in a database, for example the "jobs" page. You have master list view, an...