I need to make a gql query against a set of some objects which have a date field. I am very new to python and also the GAE so I am a bit igorant to this. I am looking in the documentation but cannot find quite what I am looking for. Basically I have made the following class method
Event.getEventsForMonth(cls, month,year):
So I am t...
I was surprised that sys.getsizeof( 10000*[x] )
is 40036 regardless of x: 0, "a", 1000*"a", {}.
Is there a deep_getsizeof
which properly considers elements that share memory ?
(The question came from looking at in-memory database tables like
range(1000000) -> province names: list or dict ?)
(Python is 2.6.4 on a mac ppc.)
Added:
10000*...
I was trying to create a simple script to open a locally hosted web site for testing the css in 2 or more browsers. The default browser is IE7 and it opens the page fine but when I try to open a non default browser such as Firefox or Arora it just fails.
I am using the webbrowser module and have tried this several way as detailed in va...
#!/usr/bin/python
str = "this"
if(1):
print "Hi"
else:
print str.any_random_function()
This doesn't fail when I run the program. I tried py_compile but that didn't indicate the error in the 'else' loop either. Now how can I compile the program and detect errors reliably in python code?
Thanks.
...
I have just read Python Cookbook. The book is amazing.
I think the best use of this book is that it provides lots of examples that show python in real problem applications. Many of the idioms include metaprogramming techniques.
I wonder if there is any catalog that summarizes metaprogramming idioms in Python?
Python Cookbook is very ...
I'm trying to figure out what IDE to use for Google App Engine development in Python. I'm completely new to Python, coming from a C#/.NET background.
I initially went down the route of getting the Eclipse plugin for Google App Engine development only to find out it was for Java development only.
Currently, I'm just using Notepad++...
Is there a single regular expression that can parse a string (in Python and Javascript, does not need to be the same expression) that represents simple boolean arithmetic? For example I want to parse this string:
a and (b and c) and d or e and (f or g)
Assuming that:
* parentheses do not nest
* the terms a, b, ..., z are not sub-expre...
I have a dictionary of lists with info such as var1=vara, var1=varb, var2=vara etc. This can have lots of entries, and I print it out ok like this
for y in myDict:
print(y+"\t"+myDict[y])
I have another list which has exclusions in like this var2, var3 etc. This may have < 10 entries and I can print that ok like this
for x ...
Can GAE be configured to bust me an email when there's an error?
...
We are in the process of upgrading from PostgreSQL 8.3 to PostgreSQL 8.4, in a large part so that we can start using certificate-based authentication.
We have some Python 2.x code that accesses the database that uses PyGreSQL. Is there a way to get it or any other Python library to use a cert to access PostgreSQL?
Looking through the P...
I am attempting to create my first OS-level GUI using wxPython. I have the book wxPython in Action and have looked at the code demos. I have no experience with event-driven programming (aside from some Javascript), sizers, and all of the typical GUI elements. The book is organized a little strangely and assumes I know far more about O...
If have a list of dictionary items like so:
L = [{"a":1, "b":0}, {"a":3, "b":1}...]
I would like to split these entries based upon the value of "b", either 0 or 1.
A(b=0) = [{"a":1, "b":1}, ....]
B(b=1) = [{"a":3, "b":2}, .....]
I am comfortable with using simple list comprehensions, and i am currently looping through the list L t...
Table structure - Data present for 5 min. slots -
data_point | point_date
12 | 00:00
14 | 00:05
23 | 00:10
10 | 00:15
43 | 00:25
10 | 00:40
When I run the query for say 30 mins. and if data is present I'll get 6 rows (one row for each 5 min. stamp). Simple Query -...
Hello,
I am using Arch linux and I need to create virtual serial port on it. I tried everything but it seems doesnt work. All I want is to connect that virtual port to another virtual port over TCP and after that to use it in my python application to communicate with python application to other side. Is that posible? Please help me.
Th...
Using Python 2.5, I'd like to create a temporary file, but add (& modify) attributes of my own. I've tried the following:
class TempFileWithAttributes ( ) :
__slots__ = [ '_tempFile' , 'Value' ]
def __init__ ( self ) :
self._tempFile = tempfile.TemporaryFile()
object.__setattr__ ( self, '_tempFile', t...
I've got a timedelta. I want the days, hours and minutes from that - either as a tuple or a dictionary... I'm not fussed.
I must have done this a dozen times in a dozen languages over the years but Python usually has a simple answer to everything so I thought I'd ask here before busting out some nauseatingly simple (yet verbose) mathema...
(in case you're curious about motivation: this will be used in a scons build to generate a C file containing a GUID)
I found the question about generating a GUID in python. But I don't really know much about programming python. Could someone help me convert this to a string of the form
"{0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, 0x**, ...
Hello,
I have this view function:
def search(request):
if request.method == 'GET':
form = SearchForm(request.GET)
if form.is_valid():
last_name = form.cleaned_data['last_name']
first_name = form.cleaned_data['first_name']
lawyers = Lawyer.objects.all()
[ other if state...
I have an "alarm email" function inside a python module. I want to be able to call this function from a bash script. I know you can call a module using 'python ' in the script, but I'm not if you can or how you would call a specific function within the module.
...
Challenge:
Perform a bitwise XOR on two equal sized buffers. The buffers will be required to be the python str type since this is traditionally the type for data buffers in python. Return the resultant value as a str. Do this as fast as possible.
The inputs are two 1 megabyte (2**20 byte) strings.
The challenge is to substantially bea...