I'm using this simple function:
def print_players(players):
tot = 1
for p in players:
print '%2d: %15s \t (%d|%d) \t was: %s' % (tot, p['nick'], p['x'], p['y'], p['oldnick'])
tot += 1
and I'm supposing nicks are no longer than 15 characters.
I'd like to keep each "column" aligned, is there a some syntactic suga...
What would be the best way to store (non-mutable) data that is of format:
doodahs = {
0-256: "FOO",
257: "BAR",
258: "FISH",
279: "MOOSE",
280-65534: "Darth Vader",
65535: "Death to all newbies" }
I have a relatively large amount of these type of data sets, so something that I can define the way of dictionaries (or close to it) and ac...
How can I make HTML from email safe to display in web browser with python?
Any external references shouldn't be followed when displayed. In other words, all displayed content should come from the email and nothing from internet.
Other than spam emails should be displayed as closely as possible like intended by the writer.
I would like...
I would like to provide database for my program that uses elixir for ORM. Right now the database file (I am using SQLite) must be hardcoded in metadata, but I would like to be able to pass this in argv. Is there any way to do this nice?
The only thing I thought of is to:
from sys import argv
metadata.bind = argv[1]
Can I set this in...
Hello,
Is it possible to add a documentation string to a namedtuple in an easy manner?
I tried
from collections import namedtuple
Point = namedtuple("Point", ["x", "y"])
"""
A point in 2D space
"""
# Yet another test
"""
A(nother) point in 2D space
"""
Point2 = namedtuple("Point2", ["x", "y"])
print Point.__doc__ # -> "Point(x, y)...
Hello,
I am trying to use Python to resize picture.
With my camera, files are all written is landscape way.
The exif information handle a tag to ask the image viewer to rotate in a way or another.
Since most of the browser doesn't understand this information, I want to rotate the image using this EXIF information and keeping every othe...
Hi,
I am writing a python app using Tkinter for buttons and graphics and having trouble getting a timer working, what I need is a sample app that has three buttons and a label.
[start timer] [stop timer] [quit]
When I press the start button a function allows the label to count up from zero every 5 seconds, the stop button stops the t...
Hello,
I have a problem with debugging Python programs under the Netbeans IDE. When I start debugging, the debugger writes the following log and error. Thank you for help.
[LOG]PythonDebugger : overall Starting
>>>[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ...
[LOG]This window is an interactive debugging c...
I have read tons of posts but still can't seem to figure it out.
I want to subprocess.Popen() rsync.exe in windows, and print the stdout in python.
My code works, but it doesn't catch the progress until a file is done transfered! I want to print the progress for each file in realtime.
Using python 3.1 now since I heard it should be be...
Say you have a list of dicts like this {'id': 1, 'other_value':5}
So maybe;
items = [{'id': 1, 'other_value':5}, {'id': 1, 'other_value2':6}, {'id': 2, 'other_value':4}, {'id': 2, 'other_value2':3}]
Now, you can assume this is a small subset of the data. There are maybe thousands. Also the structure isn't specified by me, its given t...
Hi All:
Suppose I've got 2 different modules which have the uniform(same) interfaces. The files list like this:
root/
logic.py
sns_api/
__init__.py
facebook/
pyfacebook.py
__init__.py
myspace/
pymyspace.py
__init__.py
And pyfacebook.py and pymyspace.py have the same inte...
I have a few hundred keys, all of the same Model, which I have pre-computed:
candidate_keys = [db.Key(...), db.Key(...), db.Key(...), ...]
Some of these keys refer to actual entities in the datastore, and some do not. I wish to determine which keys do correspond to entities.
It is not necessary to know the data within the entities, j...
Can I write custom Qt widget in pure C++, compile it and use in PyQt?
I'm trying to use the ctypes-opencv with qt and I have performance problems with python's code for displaying opencv's image in Qt form.
...
In Python, how do you make a subclass from a superclass?
...
I've been using Python's built-in cProfile tool with some pretty good success. But I'd like to be able to access more information such as how long I'm waiting for I/O (and what kind of I/O I'm waiting on) or how many cache misses I have. Are there any Linux tools to help with this beyond your basic time command?
...
How can I create a file in python one directory up, without using the full path?
I would like a way that worked both for windows and linux.
Thanks.
...
I've been working on my own django based blog (like everyone, I know) to sharpen up my python, and I thought added some syntax highlight would be pretty great. I looked at some of the snippets out there and decided to combine a few and write my own syntax highlighting template filter using Beautiful Soup and Pygments. It looks like this:...
I have a python dictionary object that contains a boolean for every key, e.g.:
d = {'client1': True, 'client2': False}
What is the easiest and most concise way to count the number of True values in the dictionary?
...
Hello guys. I'm not sure if i understand properly how os.walk store its results.
Im trying to do the following:
I'm checking a root folder for subsequent folders. There are several hundreds of em, and they are nested in somewaht uniform way.
I'm trying to check each subfolder, and if it ends with a four digit number, store it in a lis...
Hello all,
I'm looking at 'pygoogle' python library for google search, call from my python script. But google doesn't give out license key anymore, and looks like pygoogle needs license key to work.
Does anyone have suggestions of libraries to use for scripting web searches? Languages doesn't matter. It can be in python, perl, lisp, fo...