python

how does get the title and content of this code in django-sphinx.

i get this string: {'id': 1, 'weight': 101, 'attrs': {'date_added': 1265274382, 'group_id': 1}}{'id': 2, 'weight': 100, 'attrs': {'date_added': 1265274382, 'group_id': 1}}{'id': 4, 'weight': 100, 'attrs': {'date_added': 1265274382, 'group_id': 2}} i want to get the real data(title and content): and my view is : from djangosphinx.mo...

How to get TRUE column position in wxStyledTextCtrl?

I have a wxStyledTextCtrl and I want to find the column number of a given position in the document. Basically I want a function like GetColumn but I don't want tabs to be expanded. Does such a function exist? ...

Where would I import urllib2 for a class?

I have a class that needs access to urllib2, the trivial example for me is: class foo(object): myStringHTML = urllib2.urlopen("http://www.google.com").read() How should I structure my code to include urllib2? In general, I want to store foo in a utility module with a number of other classes, and be able to import foo by itself fr...

best (python) setup for cpu / memory intensive task

i'm doing simulation which generates thousands of result objects. Each object size is around 1mb, and all the result objects should be on memory to be queried for various ad hoc reports. And it takes 1~2 secs to make one result object. So it takes more than 5 minutes to get one simulation done even though i fully use my quad-core cpu wi...

Using Mako In Windows

I plan to use wsgi + mako in Windows. I install mako using C:\wsgi>c:\Python26\Scripts\easy_install.exe Mako No error. I get Finished processing dependencies for Mako at end of the message. I check my Python directory, I am having the following structure : C:\Python26\Lib\site-packages\mako-0.2.5-py2.6.egg C:\Python26\Lib\site-...

can i make a field in database use this django code ,and don't use 'python manage.py startapp xx'

from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) can i ??? thanks ...

How to integrate pyode with python..

Hi..I am tryin to integrate vpython with Pyopengl to get output in a single window..is it possible..?? Also can anyone suggest good reference for pyode? ...

Searching a 2-Dimensional Tuple/List in Python

I want to search a tuple of tuples for a particular string and return the index of the parent tuple. I seem to run into variations of this kind of search frequently. What is the most pythonic way to do this? I.E: derp = (('Cat','Pet'),('Dog','Pet'),('Spock','Vulcan')) i = None for index, item in enumerate(derp): if item[0] == 'Spo...

Is there a way to turn XML into dictionary and lists?

<things> <fruit>apple</fruit> <hardware>mouse</hardware> ... </things> Turn it into: {'things':[{'fruit':'apple'}, {'hardware':'mouse'}]} Is there an easy way to do this? Thanks. ...

Python regex problem

What I am trying to do: Parse a query for a leading or trailing ? which will result in a search on the rest of the string. "foobar?" or "?foobar" results in a search. "foobar" results in some other behavior. This code works as expected in the interpreter: >>> import re >>> print re.match(".+\?\s*$","foobar?") <_sre.SRE_Match obj...

Python Dictionary Binary Search Tree

I am struggling to get to know how to code a basic implementation using a dictionary and in-order traversal binary search tree in Python. The class have to be using the below structure. I would be very happy if someone could fill out the blanks (pass) in each function to get me started. class Dictionary: def __init__ (self): ...

Problems using the python WConio library

I'm trying to use the WConio library for python, but when I import it, it gives this error: Traceback (most recent call last): File "WConioExample.py", line 15, in < module> import WConio File "d:\tools\development\python2.5\lib\site-packages\WConio.py", line 23, in from _WConio import * ImportError: DLL load fai...

Print string in a form of Unicode codes

How can I print a string as a sequence of unicode codes in Python? Input: "если" (in Russian). Output: "\u0435\u0441\u043b\u0438" ...

global variable from django to javascript

I would like some variables from my settings.py to be available in every javascript running across my project. What is the most elegant way of achieving this? Right now I can think of two: write a context processor and declare those globals in a base template. All templates must extend the base template. declare those globals in a dy...

Debugging a subprocess.Popen call

I have been using subprocess.Popen successfully in the past, when wrapping binaries with a python script to format arguments / customize etc... Developing a nth wrapper, I did as usual... but nothing happens. Here is the little code: print command p = subprocess.Popen(command, shell = True) result = p.communicate()[0] print vars(p) re...

moving a function out of my method in django

Hay i have a method in my view which uploads an image, the image is then saved to a db object. I want to remove this from my view and either put it in my model or a seperate file. filename_bits = request.FILES['image'].name.split(".") filename_bits.reverse() extension = filename_bits[0] # create filename and open a destination filename...

How do I do this with Python list? (itemgetter?)

[{'id':44}, {'name':'alexa'},{'color':'blue'}] I want to select whatever in the list that is "id". Basically, I want to print 44, since that's "id" in the list. ...

Accessing C header magic numbers/flags with Cython

Some standard C libraries that I want to access with Cython have a ton of flags. The Cython docs state that I must replicate the parts of the header I need. Which is fine when it comes to functions definitions. They are usually replicated everywhere, docs included. But what about all those magic numbers? If I want to call mmap, I can a...

pyqt jpeg support not working in bundled form

To enable jpeg support in a PyQT application, you have to manually include the qjpeg4.dll. It works fine when the dll and pyd file are not bundled together in the final exe. For example with py2exe you can do the following : DATA=[('imageformats',['C:\\Python26/Lib/site-packages/PyQt4/plugins/imageformats/qjpeg4.dll'])] setup(console=[{...

Verify RTSP service via URL

Hello, I am trying to verify that a video service is provided from an URL in python. I am asking does anyone know of any good libraries to use or a way to do this. I have not found much info for this on the web. Thanks ...