python

Django Model/Database design for subclasses

Hi. Ok, i'm shit at describing. Here's a relationship diag. In Django i've made my models like: from django.db import models from datetime import datetime class Survey(models.Model): name = models.CharField(max_length=100) pub_date = models.DateTimeField('date published',default=datetime.now) def __unicode__(self): ...

What is the Python equivalent of java.util.zip.Inflater?

I have a Java program that opens a socket connection to a server that streams Zip compressed data. I read(bytebuffer) from the stream, setInput(bytebuffer) on the zip object, and inflate(outputbuffer) to get my uncompressed data. What would be the equivalent in python? Here is the java code: byte[] compressedBytes = new byte[1024]; in...

How do I install .pl plugins for nagios?

I am trying to install the "check_mssql_sproc.pl" plug in for nagios. Where and how do I install it? ...

What is the space complexity of HashTable, Array, ArrayList, LinkedList etc(if anything more)

I want to know the space complexities of the basic data structures in popular languages. ...

Getting a WxPython panel item to expand

I have a WxPython frame containing a single item, such as: class Panel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.text = wx.StaticText(self, label='Panel 1') I have a frame containing several panels, including this one, and dimensions are ruled by sizers. I would like this StaticTex...

Selecting data from Google App Engine datastore by field value

I'm just staring off with GAE. So like many I'm used to standard SQL. Typically when you want to select data that has a certain field value you use: SELECT <columns> FROM <table> WHERE <column> = <wanted value> Is the correct way to do this in GAE <Model Class>.all().filter('<column> =', <wanted value>) Or is there a more efficien...

Python/django inherit from 2 classes

In my django project I have 2 variations of users. One subclasses User class from django.auth and second uses almost the same fields but is not a real user (so it doesn't inherit from User). Is there a way to create a FieldUser class (that stores fields only) and for RealUser subclass both FieldUser and User, but for FakeUser subclass on...

how to get all "index data" using whoosh ..

i use whoosh for full text search , and i want to know : how to get all 'index data ' that be added. this is my main.py import cgi,os from google.appengine.ext import webapp from google.appengine.ext.webapp import template from google.appengine.ext.webapp.util import run_wsgi_app from whoosh import store from whoosh.fields import Sc...

Inverse Distance Weighted (IDW) Interpolation with Python

The Question: What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations? Some Background: Currently I'm using RPy2 to interface with R and it's gstat module. Unfortunately, the gstat module conflicts with arcgisscripting which I got around by running RPy2 based analysis in a separate...

Cross-platform Python GUI suitable for taskbar (Win) and menubar (mac) functionality ?

I am fairly new to Python programming, and completely new to cross-platform GUI building (only previous GUI experience is through visual basic and Java). I've written some python code to screen-scrape data from a website, and now I want to build a GUI that will reside in the Mac OS X menubar, and in Window's task bar (i.e., the system tr...

google-app-engine full-text-search ,which is better , "google custom search" or whoosh.

this is whoosh so ,did you know which is better ? thanks ...

how do I set a value for a ShapeKey in Blender Python ?

I've managed to insert Shape Keys from Python using: ob = Scene.GetCurrent().object.active; if(ob.activeShape == 0): ob.insertShapeKey() ob.insertShapeKey() Now how do I change a key value ? ...

Python: Printing Unicode to File

file = open('unicode.txt', 'wb') for i in range(10): file.write(str(unichr(i) )) What i would like to do is to print all of the Unicode values to a text file ...

Concatenate tuples in empty dict

errors = {} #errorexample errors['id'] += ('error1',) errors['id'] += ('error2',) #works but ugly errors['id'] = ('error1',) errors['id'] += ('error2',) If 'error1' is not present it will fail. Do I really have to extend dict? ...

Python SQLite parameter substitution with wildcards in LIKE

I am attempting to use a parametrized LIKE query with Python's Sqlite library as below: self.cursor.execute("select string from stringtable where string like '%?%' and type = ?", (searchstr,type)) but the ? inside of the wildcard is not being evaluated leaving me with this error: "sqlite3.ProgrammingError: Incorrect number of bindings...

Using C++ from Python? (not boost)

I'm currently using boost-python to wrap a small C++ library and make it usable from Python. However, I'd like to stop using boost (mainly due to reasons relating to building/linking). So what other options are there? Is there something that's equally convenient to use? ...

How do you automatically remove the preview window after autocompletion in Vim?

I'm using omnifunc=pythoncomplete. When autocompleting a word (e.g., os.), I get the list of eligible class members and functions, as expected, as well as a scratch buffer preview window with documentation about the selected member or function. This is great, but after selecting the function I want, the preview window remains. I can get ...

Python: Convert args to dict, like PHP's compact?

I want a function exactly like PHP's compact function. i.e., if I pass in a list of variable names: compact('var1','var2') it returns me back a dict: {'var1':var1, 'var2':var2} ...

Dynamically generating a generator function from a blob of text

(Simplified from an excessively verbose question I posted earlier!) Given a Python string containing valid Python code that contains a "yield" statement, how can I construct a generator that exec's that string? For example, given the string: code_string = """for x in range(0, 10): yield x """ I want to construct a generator f th...

index a list in a Python for loop

I'm making a for loop within a for loop. I'm looping through a list and finding a specific string that contains a regular expression pattern. Once I find the line, I need to search to find the next line of a certain pattern. I need to store both lines to be able to parse out the time for them. I've created a counter to keep track of the...