So I've made a game in Python and PyGame. Now I'm interested in submitting the game to Intel's March Developer Challenge. However, the developer challenge requires use of Intel's Atom Developer SDK (http://appdeveloper.intel.com/en-us/sdk), which only has API's for C and C++.
I'm new to Python and PyGame, and have no experience in C or...
I have a model with a bunch of different fields like first_name, last_name, etc. I also have fields first_name_ud, last_name_ud, etc. that correspond to the last updated date for the related fields (i.e. when first_name is modified, then first_name_ud is set to the current date).
Is there a way to make this happen automatically or do I...
Given the following function:
def foo(a, b, c):
pass
How would one obtain a list/tuple/dict/etc of the arguments passed in, without having to build the structure myself?
Specifically, I'm looking for Python's version of JavaScript's arguments keyword or PHP's func_get_args() method.
What I'm not looking for is a solution using *...
I'm trying to figure out the best way to create a class that can modify and create new users all in one. This is what I'm thinking:
class User(object):
def __init__(self,user_id):
if user_id == -1
self.new_user = True
else:
self.new_user = False
#fetch all records from db about user_id
...
In another question, the accepted answer suggested replacing a (very cheap) if statement in Python code with a try/except block to improve performance.
Coding style issues aside, and assuming that the exception is never triggered, how much difference does it make (performance-wise) to have an exception handler, versus not having one, ve...
I am developing an app for Nokia 5800 Music Express (S60 5th edition) using PyS60 (Python for S60) ,I want to simulate a KeyPress say if a message comes,I detect a message and Press a Key.
There does exist a Keypress module for PyS60 for 2nd edition phones which allows this. However I have not been able to install it on my 5th ed phone...
Hi,
I am using the column validator in the SQLAlchemy ( http://stackoverflow.com/questions/2317081/sqlalchemy-maximum-column-length ) but I have one problem which corresponds with the Session.
First of all, I create a table using the declarative base (sqlalchemy.ext.declarative) where InstallValidatorListeners is the validator class (se...
I am trying to find a frequency of each symbol in any given text using an algorithm of O(n) complexity. My algorithm looks like:
s = len(text)
P = 1.0/s
freqs = {}
for char in text:
try:
freqs[char]+=P
except:
freqs[char]=P
but I doubt that this dictionary-method is fast enough, because it depends on the ...
I have an application which obtains data in JSON format from one of our other servers. The problem I am facing is, there is is significant delay when when requesting for this information. Since a lot of data is passed (approx 1000 records per request where each record is pretty huge) is there a way that compression would help reducing th...
Following up on my last year's question on documentation, I now want to get started and try out Python-based Sphinx for putting together the developer documentation for a PHP CMS I've been working on.
Instead of setting up Python locally on my workstation, I would like to run it on a publicly accessible web server from the start. All th...
Hi!
I'am developing application on app-engine-path.
I would like to make form with multichoice (acceptably languages for user).
Code look like this:
Language settings:
settings.LANGUAGES = ((u"cs", u"Čeština"), (u"en", u"English"))
Form model:
class UserForm(forms.ModelForm):
first_name = forms.CharField(max_length=100)
...
I wrote a function in Python which is used to tell me whether the two words are similar or not.
Now I want to pass Japanese text in my same function. It is giving error "not a ascii character." I tried using utf-8 encoding, but then it giving the same error
Non-ASCII character '\xe3' in file
Is there any way to do that? I cant genera...
I ran cprofile on a bit of code, which among other things spawns several threads that do most of the work.
When I looked at the output of the profiling, I see no logging of all the functions that were called inside the threads. I am sure they were called, as they do stuff that is easy to see such as writing to a DB etc.
Does cProfile no...
Given two lists:
chars = ['ab', 'bc', 'ca']
words = ['abc', 'bca', 'dac', 'dbc', 'cba']
how can you use list comprehensions to generate a filtered list of words by the following condition: given that each word is of length n and chars is of length n as well, the filtered list should include only words that each i-th character is in th...
If a lot of nested dictionarys, I am trying to find a certain key.
this key is called "fruit". But it's nested inside somewhere. How do I find the value of this key?
...
I want to make Waf generate a beep when it finishes the execution of any command that took more than 10 seconds.
I don't know how do add this and assure that the code executes when Waf exits.
This should run for any Waf command not only build.
I checked the Waf book but I wasn't able to find any indication about how should I do this...
in server side, not browser.
...
Would what mentioned in the title be possible? Python module style that is. See this example for what I exactly mean.
index.php
<?php
use Hello\World;
World::greet();
Hello/World.php
<?php
namespace Hello\World;
function greet() { echo 'Hello, World!'; }
Would this be possible?
...
Hello,
I have a function which returns 3 numbers, e.g.:
def numbers():
return 1,2,3
usually I call this function to receive all three returned numbers e.g.:
a,b,c=numbers()
However, I have one case in which I only need the first returned number.
I tried using:
a, None None = numbers()
But I receive "SyntaxError: assignment t...
Does Python offer a way to iterate over all "consecutive sublists" of a given list L - i.e. sublists of L where any two consecutive elements are also consecutive in L - or should I write my own?
(Example: if L = [1, 2, 3], then the set over which I want to iterate is {[1], [2], [3], [1, 2], [2,3], [1, 2, 3]}. [1, 3] is skipped since 1 a...