python

Can pygame use vector art?

http://cache.kotaku.com/assets/resources/2008/02/dbzburstcell.jpg -edit- bassically just detailed vectorized 2d games. When making a side scroller in pygame or any other comparable 2d framework with python, can you utilize graphics such as in the above link? Thanks. ...

Difference between random draws from scipy.stats....rvs and numpy.random

Hi, It seems if it is the same distribution, then random draws from numby.random is faster than that from scipy.stats.....rvs. I was wondering what causes the speed difference between the two. -Joon ...

determining a consonant and vowel count in a string

m=input("Enter A Word (in lowercase): ") i=0 length=0 for i in m: length=length+1 if "a">m>"z" : print("Input:" + m +" is incorrect! Please try again.") b=True elif "A"<=m<="Z" or "A">m>"Z": b=True print("Input:" + m +" is incorrect! Please try again.") elif "a"<=m<="z": b=False while b==False: for x ...

How to initialize empty list?

Every time the input s comes from the form; the list is initialized again. How do I change the code to append each new s to the list? Thank you. class Test(webapp.RequestHandler): def get(self): s = self.request.get('sentence') list = [] list.append(s) ...

python promblem(for loops)

Possible Duplicate: determining a consonant and vowel count in a string for x in range(length): for y in range(x+1,length): if "a"<=m[x]<="z" and "a"<=m[y]<="z": i=0 count=0 for i in range(length): if m[i]=="a" or m[...

Change how Python Cmd Module handles autocompletion

I have a Cmd console set up to auto-complete card names for a Magic: the Gathering collection management system. It uses the text parameter to query the database for cards, and uses the results to auto-complete/suggest cards. However, these cards names have multiple words, and Cmd runs auto-completion from the last space to the end of ...

How to detect and convert progressive jpegs with python

I'd like to be able to detect progressive jpegs using python and convert them to non progressive. (I'm writing a tool to manage images for android and progressive jpegs seem to break it.) ...

extract a sentence using python

I would like to extract the exact sentence if a particular word is present in that sentence. Could anyone let me know how to do it with python. I used concordance() but it only prints lines where the word matches. ...

How can I distinguish lists from strings in django templates

I'm developing a project on Google AppEngine, using Django templates, so I have to use tags like {{ aitem.Author }} to print content within my HTML template. Author, however, can either be a string or a list object, and I have no way to tell it in advance. When the Author is a list and I try to print it on my template, I get the ugly re...

Python Regular Expression Matching: ## ##

Im searching a file line by line for the occurrence of ##random_string##. It works except for the case of multiple #... pattern='##(.*?)##' prog=re.compile(pattern) string='lala ###hey## there' result=prog.search(string) print re.sub(result.group(1), 'FOUND', string) Desired Output: "lala #FOUND there" Instead I get the following...

Can I reliably figure out the correct mime type to serve untrusted content?

Say I let users upload files to my server, and I let users download them. I'd like to set the mime type to something other than just application/octet-stream, so that if the browser can just open them, it does (say, for images, pdf files, plain text files, etc.) Of course, since the files are uploaded by users, I can't trust the file e...

How come when I use the tComment VIM plugin in a .ini file it adds/removes semi-colons instead of hashes as comment?

I am using gVIM and the tComment plug-in during editing the development.ini file in a Pylons/Python project. The default development.ini file has lines commented out using the hash # symbol which is the standard method of commenting out lines in Python. However, when I try to uncomment lines by using a tComment keyboard shortcut in gVIM,...

pygame: custom classes inheriting from pygame.Surface

Hello all, I'm playing with pygame for the first time (and am kind of a newb about python in general), and wondering if anyone could help me with this... I'm making a little shootem-up game and want to be able to create a class for bad guys. My thought was that the class should inherit from pygame.Surface, but that's giving me all kinds...

What would be some orthogonal or non-orthogonal features in Python?

What would be some orthogonal or non-orthogonal features in Python? Can you give some examples? ...

Python: Optimize this loop~~~~~~~~~~~

a = [(1,2),(3,1),(4,4),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5),(5,5)] # Quite a lot tuples in the list, 6 digits~ # I want to split it into rows and columns. rows = 5 cols = 5 Data structure is rows and cols are the index for the bit list [rows, cols, (data)] I use loop to do this, but it ta...

Python Regular Expression Matching, help please!

Possible Duplicate: Python Regular Expression Matching: ## ## I already asked this question, but let me restate it better... Im searching a file line by line for the occurrence of ##random_string##. It works except for the case of multiple #... pattern='##(.*?)##' prog=re.compile(pattern) string='lala ###hey## there' result=...

Using python and the bittorrent protocol

I wanted to write a program with could send and receive data over a NAT router without having to set up port forwarding first. Do i need to use the bittorrent protocol or is there something better? ...

How can I use a Perl module from Python?

There exists a Perl module that provides the perfect functionality for my Python app. Is there any way for me to utilize it? (it is complicated, it would take me a month to port it) I don't want to have to spawn a subprocess for every usage, as I need it several hundred thousand times (it is a specific type of data parser). Thanks fo...

Python Simulation: Total Website Traffic Qty Estimation using Personas Segments

Hi. I need to estimate future website traffic & conversion volume based on: 1) Baseline historical averages for 6 differing types of traffic segments 2) How each of those distinct visitor segments interacts with 5 unique content groups After searching the internet I've concluded modules exist that can easily be adapted to fit my as...

Getting the Tasks in a Google App Engine TaskQueue

I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and/or cancel them. In python please. ...