python

Split a key that is a string of numbers into single digit keys in Python.

I would like to turn the following dictionary: dictionary = { 4388464: ['getting'] 827862 : ['Taruma', 'Varuna'] ... } into: dictionary = { 4: {3: {8: {8: {4: {6: {4: {'words': ['getting']}}}}}}} 8: {2: {7: {8: {6: {2: {'words': ['Taruma', 'Varuna']}}}}}} ... } This will then allow me to use the dictionary l...

PyQt4: My database displays empty cells

Hello everyone. I am using the pyqt4 framework to do some displays for database forms. Unfortunately, I hit a snag while trying to filter and display my database by last name. Assume that the database connection works. Also assume that I have the correct amount of items in my tupleHeader since I use the same initializeModel method fo...

Django: Filtering datetime field by *only* the year value?

Hi folks, I'm trying to spit out a django page which lists all entries by the year they were created. So, for example: 2010: Note 4 Note 5 Note 6 2009: Note 1 Note 2 Note 3 It's proving more difficult than I would have expected. The model from which the data comes is below: class Note(models.Model): business = models.Forei...

Importing Python modules without installing - Sybase ASE

I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possib...

Avoid 404 page override

I 'm using django-lfs with default django-app.Its appear django-lfs override 404 default template. How to avoid this process ...

Parsing timestamp with Python2.4

I want to parse a timestamp from a log file that has been written via datetime.datetime.now().strftime('%Y%m%d%H%M%S') and then compute the number of seconds that have passed since this timestamp. I know I could do it with datetime.datetime.strptime to get back a datetime object and then compute a timedelta. Problem is, the strptime f...

Matching a+ in a regex

This should be easy, but I've managed to stump 2 people so far at work & I've been at it for over 3 hours now, so here goes. I need to replace a+ with aplus (along with a few other cases) with the Python re module. eg. "I passed my a+ exam." needs to become "I passed my aplus exam." Just using \ba+ works fine most of the time, but fai...

Coversion of exchange server's fetched XML to Google Calendar compitable XML

I want to migrate my calendar from exchange server to Google calendar, I fetched exchange server's XML now I have to pass that XML to google calendar's python code so that my calendar can be set, Now my question is how can i convert my exchange server's XML to Google's compatible XML? ...

If Python is interpreted, what are .pyc files?

I've been given to understand that Python is an interpreted language... however, when I look at my Python source code I see .pyc files, which Windows identifies as "Compiled Python Files". Where do these come in? ...

Getting youtube links from embedded youtube video on pages?

Is there a regex to get youtube video links or ids from embedded youtube videos on webpages? ...

How to make every Class Method call a specified method before execution?

I want to make my Python Class behave in such a way that when any Class method is called a default method is executed first without explicitly specifying this in the called Class. An example may help :) Class animals: def _internalMethod(): self.respires = True def cat(): self._internalMethod() self.name...

Implementing QItemEditorCreatorBase in PyQt4

I tried to implement QItemEditorCreatorBase to get QComboBox editor for colors in a table. So I wrote an editor: class ColorListEditor(QtGui.QComboBox): def __init__(self, parent=None): super(ColorListEditor, self).__init__(parent) self.populateList() def populateList(self): for i, name in enumerate(QtGui.QColor.colorNames(...

Does Python work in larger teams?

I read this post last night and it got me thinking. I like python and "batteries", pypi and such. But I've only done python solo. Never tried it in a team. Are the points that Ted mentions valid? If they are how do teams cope with them? Does Python work in teams or even large teams? Or it kills productivity? I personally see the proble...

Passing values into regex match function

In python (it's a Django filter), I'm doing this: lReturn = re.sub(r'\[usecase:([ \w]+)]', r'EXTEND WITH <a href="/usecase/%s/\1/">\1</a>' % pCurrentProjectName, lReturn) I'd like to use a function instead of a string (so I can check that the usercase is a valid name), so it would change to this: def _match_function(matchobj): lM...

Specifying the Python interpreter for vim's :python command

(Mac)Vim seems to be picking up /usr/bin/python instead of the one that's at the front of my path (/Library/Frameworks/Python.framework/Versions/2.6/bin/python) when I use the :python command. Is this entirely a compile-time thing or can I somehow override it? ...

i18n with webpy

Hello, i Have a problem with i18n, using webpy. I have followed this : http://webpy.org/cookbook/i18n_support_in_template_file So, in my .wsgi there is : #i18n gettext.install('messages',I18N_PATH,unicode=True) gettext.translation('messages',I18N_PATH,languages=['fr_FR','en_US']).install(True) So i ran : pygettext.py -a -v -d messa...

Python: split files using mutliple split delimiters

Hi, I have multiple CSV files which I need to parse in a loop to gather information. The problem is that while they are the same format, some are delimited by '\t' and others by ','. After this, I want to remove the double-quote from around the string. Can python split via multiple possible delimiters? At the minute, I can split the l...

Getting py2exe to work

Hello all. I am following the the tutorial at http://www.py2exe.org/index.cgi/Tutorial to figure out how to use py2exe. I get down to step 3 where you are suppose to run the command: python setup.py py2exe I do that and then I get this error: 'python' is not recognized as an internal or external command, operable program or batch fil...

Python File Meta Tag reading

Anyone know of a Python module that can pull Tag data from multiple media formats? Trying to build an app that allows for manipulation of ASF (Windows Media Player files, ie WMA, WMV, etc), ID3, including both ID3v1 and ID3v2 (MPEG files, ie MP3), MPEG Audio Bit Stream (ie ABS, MP1, MP2, MP3), MPEG Program Stream (MPEG movies, and DVD a...

how to create URL extractor like facebook share

i need to extract data from url like title , description ,and any vedios images in the given url like facebook share button like this : http://www.facebook.com/sharer.php?u=http://www.wired.com&amp;t=Test regards ...