Google App Engine has free quota limit of 1.00 GBytes for Total Stored Data. My current application has exceeded that limit causing system to generate 500 Internal Error messages. There is no easy way to remove data from DataStore.
My trick is to delete records in batch and using loop until you get DeadlineExceededError Exception. Typically I can remove 1000 rows per call
You can schedule cron job to execute this code every hour so old records are deleted automatically
start=time.time()
date_keep=(datetime.date.today()-datetime.timedelta(days=30)).isoformat()
sql="SELECT __key__ FROM TBL_TOP_URL WHERE UPDATED < DATE('"+date_keep+"') LIMIT 100"
print sql
rows=[None]
while len(rows) <> 0:
query = db.GqlQuery(sql)
rows = query.fetch(100)
print 'len(rows):',len(rows)
db.delete(rows)
print time.time() - start
if len(rows) > 0:
print rows[-1].id()
Python is open source software and mature language. You can create commercial software using free tools with Python.
I have developed GPS tracks plotting software with elevation information in 3D space. Mapsource gives you only 2 dimensional view so gradient is not visible and you loose a lot of information
I have used wxPython for the GUI and py2exe to create software distribution package
GPS tracks data is read from .GPX file which needs to be exported from Mapsource
Have a look if you own GPS device such as Garmin or others
There is very nice free Chess GUI software that is bundled with free chess engines. The strongest engine is Rybka. It should be possible to write chess engine in Python. 1st step should be to develop interface using WinBoard text standard. I have already developed logic to work out valid moves, next step is to decide which move is best. This project will be successful when chess playing program can beat the programmer that wrote it !
to sort simple list simply call sort() method
list=[5,4,3,2,1] list.sort() print list [1, 2, 3, 4, 5]
to reverse list call reverse() method
list.reverse() print list [5, 4, 3, 2, 1]
easy but how to sort nested list below ?
list=[(5,'five'),(4,'four'),(3,'three'),(2,'two'),(1,'one')]
def sortby(list, n):
nlist = map(lambda x, n=n: (x[n], x), list)
nlist.sort()
return map(lambda (key, x): x, nlist)
list=sortby(list,0) # 0 is first element
print list
[(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five')]
you could sort by second element in the list by calling
list=sortby(list,1) # 1 is second element
Python 2.5 comes with "conditional expressions"
As developer you often would like to write one liners to assign value to variable which is based on logical condition
old style
if condition:
x = true_value
else:
x = false_value
new style
x = true_value if condition else false_value
saves you time but takes time to remember new syntax !
:: Next Page >>
Forum to discussion of Python Programming Language
| Next >
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
| << < | > >> | |||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||