I've decided to start working on programming an old favorite of mine. I've never done a game before and also never done a large project in Python.
The game is the old Avalon Hill game Russian Campaign
I've been playing with PyGame a little bit and was wondering if there were reasons not to try to do this with PyGame and go after some o...
I'm using pygame (1.9.0rc3, though this also happens in 1.8.1) to create a heatmap. To build the heatmap, I use a small, 24-bit 11x11px dot PNG image with a white background and a very low-opacity grey dot that stops exactly at the edges:
The area around the dot is perfect white, #ffffff, as it should be. However, when I use pygame to...
M2Crypto package is not showing the 'recipient_public_key.pem' file at linux terminal.
How do I get/connect with recipient public key.
Exactly, I need to check how can I open this file through linux commands.
import M2Crypto
def encrypt():
recip = M2Crypto.RSA.load_pub_key(open('recipient_public_key.pem','rb').read())
print re...
I'm experiencing what I would consider somewhat strange behavior. Specifically if I have a string like this:
1984: Curriculum Unit
by Donald R. Hogue, Center for Learning, George Orwell
"A center for learning publication"--Cover.
It results in the following after being auto-escaped by the Django template s...
I am trying to write a function that will take an xml object, an arbitrary number of tags, defined by tuples containing a tag name, attribute and attribute value (e.g ('tag1', 'id', '1')) and return the most specific node possible. My code is below:
from xml.dom import minidom
def _search(object, *pargs):
if len(pargs) == 0:
...
I've written my own implementation of QGraphicsView.drawItems(), to fit the needs of my application. The method as such works fine, however, it is called repeatedly, even if it does not need to be redrawn. This causes the application to max out processor utilization.
Do I need to somehow signal that the drawing is finished? I read the so...
I'm pretty new to Python and App Engine, but what I'm trying to do is store a model which contains a DateProperty, and that DateProperty is populated with a Date entered by the user in a web form.
I've got the model of:
class Memory(db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date = db....
Hi,
I want to use Python to get the group id to a corresponding group name.
The routine must work for Unix-like OS (Linux and Mac OS X).
Best,
~S
Edit: This is what I found so far
>>> import grp
>>> for g in grp.getgrall():
... if g[0] == 'wurzel':
... print g[2]
...
touch is a Unix utility that sets the modification and access times of files to the current time of day. If the file doesn't exist, it is created with default permissions.
How would you implement it as a Python function? Try to be cross platform and complete.
(Current Google results for "python touch file" are not that great, but poin...
Hi,
If I have files x.py and y.py . And y.py is the link(symbolic or hard) of x.py .
If I import both the modules in my script. Will it import it once or it assumes both are different files and import it twice.
What it does exactly?
...
I have a bunch of sorted lists of objects, and a comparison function
class Obj :
def __init__(p) :
self.points = p
def cmp(a, b) :
return a.points < b.points
a = [Obj(1), Obj(3), Obj(8), ...]
b = [Obj(1), Obj(2), Obj(3), ...]
c = [Obj(100), Obj(300), Obj(800), ...]
result = magic(a, b, c)
assert result == [Obj(1), Obj(...
I may have a classic problem, but I didn't find any snippet allowing me to do it.
I want to sort this model by its fullname.
class ProductType(models.Model):
parent = models.ForeignKey('self', related_name='child_set')
name = models.CharField(max_length=128)
def get_fullname(self):
if self.parent is None:
...
I have a C application and I want to include a Scripting Language to put certain functionality into scripts. I just have no experience with that and don't know exactly where to start (Still learning C and trying to understand the application).
How does embedding and communication between my app and the scripts actually work? I think I n...
I'm looking for a fast way to apply a new palette to an existing 8-bit .png image. How can I do that? Is the .png re-encoded when I save the image? (Own answer: it seems so)
What I have tried (edited):
import Image, ImagePalette
output = StringIO.StringIO()
palette = (.....) #long palette of 768 items
im = Image.open('test_palette.png'...
I have some code I developed in python 2.4++ and you bet, I have to backport it to python 2.1!
function decorators were so attractive that I have used @classmethod at a few spots, without taking notice of the fact that it is only available starting at version 2.4. the same functionality is offered by function modifiers but these appear...
I have 2 csv files. I need to replace a column in one file with a column from the other file but they have to stay sorted according to an ID column.
Here's an example:
file1:
ID, transect, 90mdist
1, a, 10, ...
I'm trying to setup a custom site-package directory (Python 2.6 on Windows Vista). For example the directory should be '~\lib\python2.6' ( C:\Users\wierob\lib\python2.6). Hence calling 'setup.py install' should copy packages to C:\Users\wierob\lib\python2.6.
Following the instructions here:
I've created a pth-file in site-packages dire...
When signing up for new accounts, web apps often ask for the answer to a 'security question', i.e. Dog's name, etc.
I'd like to go through our database and look for instances where users just mashed the keyboard instead of providing a legitimate answer - this is a high indicator of an abusive/fraudulent account.
"Mother's maiden name?"...
I have a file structure that looks something like this:
project1_root/
tests/
...
src/
.ropeproject/
project1/
... (project1 source code)
project2_root/
tests/
...
src/
.ropeproject/
project2/
... (project2 source)
I'm frequently switching back an...
Does the built-in Python math library basically use C's math library or does Python have a C-independent math library? Also, is the Python math library platform independent?
...