python

Using Pylint with Django

I would very much like to integrate pylint into the build process for my python projects, but I have run into one show-stopper: One of the error types that I find extremely useful--:E1101: *%s %r has no %r member*--constantly reports errors when using common django fields, for example: E1101:125:get_user_tags: Class 'Tag' has no 'objec...

How can I read a Word 2007 .docx file?

I'd like to search a Word 2007 file (.docx) for a text string, e.g., "some special phrase" that could/would be found from a search within Word. Is there a way from Python to see the text? I have no interest in formatting - I just want to classify documents as having or not having "some special phrase". Thanks! Gerry ...

python regular expression to split paragraphs.

How would one write a regular expression to use in python to split paragraphs? A paragraph is defined by 2 linebreaks (\n). But one can have any ammount of spaces/tabs together with the line breaks, and it still should be considered as a paragraph. I am using python so the solution can use python's regular expression syntax which is ex...

How do you create an osx application/dmg from a python package?

I want to create a mac osx application from python package and then put it in a disk image. Because I load some resources out of the package, the package should not reside in a zip file. The resulting disk image should display the background picture to "drag here -> applications" for installation. ...

Best practices for manipulating database result sets in Python?

I am writing a simple Python web application that consists of several pages of business data formatted for the iPhone. I'm comfortable programming Python, but I'm not very familiar with Python "idiom," especially regarding classes and objects. Python's object oriented design differs somewhat from other languages I've worked with. So, eve...

How to Retrieve name of current Windows User (AD or local) using Python?

How can I retrieve the name of the currently logged in user, using a python script? The function should work regardless of whether it is a domain/ad user or a local user. ...

What is the scope for imported classes in python?

Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags! The Problem I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the exact mechanism at work here, I can describe it much...

Python and POST data

In PHP I simply write: $bob = $_POST['bob']; How do I do the same in Python? And yes, I do normally check that it exists etc, I'm just stripping it down specifically to the functionality I am after. Edit: I am not using a framework ...

How to update a Tix.ComboBox's text?

I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update? Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text field currently has the value "...

How do I get a decimal value when using the division operator in Python?

For example, the standard division symbol '/' rounds to zero: >>> 4 / 100 0 However, I want it to return 0.04. What do I use? ...

What's the Name of the Python Module that Formats arbitrary Text to nicely looking HTML?

A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only. Unfortunately I lost the name of the library and was unable to Google it. Anyone any ideas? Edit: re...

How do I use timezones with a datetime object in python?

How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone() import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone""" def utfoffset(self, dt): ...

What are good open source projects in Python for which I can be a contributor?

I have been learning and using Python for the last several months and I am interested in getting involved in open source projects using Python so as to be exposed to good implementations of Python in the real world. What are some that folks recommend? (If at all possible please try to provide just one project per answer.) ...

Can you do LINQ-like queries in a language like Python or Boo?

Take this simple C# LINQ query, and imagine that 'db.Numbers' is an SQL table with one column, Number: var result = from n in db.Numbers where n.Number < 5 select n.Number; This will run very efficiently in C#, because it generates an SQL query something like "select Number from Numbers where Number < 5". What it ...

Debug/Monitor middleware for python wsgi applications

I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields. Something like firefox live headers, but for the server side. ...

How can i parse a comma delimited string into a list (caveat)?

I need to be able to take a string like: '''foo, bar, "one, two", three four''' into: ['foo', 'bar', 'one, two', 'three four'] I have an feeling (with hints from #python) that the solution is going to involve the shlex module. ...

How do I develop and create a self-contained PyGTK application bundle for MacOS, with native-looking widgets?

I have read that it is possible to build GTK+ on MacOS X. I know that it's possible to create a bundle of a GTK+ application on MacOS. I also know that it's possible to create widgets that look sort of native. However, searching around I am not really clear on how to create a bundle that includes the native theme stuff, and uses Pytho...

Python Regex vs PHP Regex

No not a competition, it is instead me trying to find why a certain regex works in one but not the other. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) That's my Regex and I'm trying to run it on 127.255.0.0 Using Python...

What's the best dispatcher/callback library in Python?

I need to allow other Python applications to register callback functions for events in my application. These need to have priorities associated with them (so a callback with a priority of 10 runs before a callback with a priority of 1) and callback functions need to be able to signal errors to the dispatcher. These are all lightweight ...

How to start IDLE (Python editor) without using the shortcut on Windows Vista?

I'm trying to teach Komodo to fire up IDLE when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving this path to Komodo causes it to say that 1 is returned. This appears to be a failure...