python

Copying modules into Django, "No module named [moduleName]"

I run into this problem pretty consistently... keep in mind I am quite new to Django and a total Python amateur. It seems that, for example, whenever I check out my Django project on a new computer after a clean install of Python and Django, it can never find the project/apps I create or copy in. So right now I have an app that is work...

Small Tables in Python?

Let's say I don't have more than one or two dozen objects with different properties, such as the following: UID, Name, Value, Color, Type, Location I want to be able to call up all objects with Location = "Boston", or Type = "Primary". Classic database query type stuff. Most table solutions (pytables, *sql) are really overkill for su...

How do I parse an HTTP date-string in Python?

Is there an easy way to parse HTTP date-strings in Python? According to the standard, there are several ways to format HTTP date strings; the method should be able to handle this. In other words, I want to convert a string like "Wed, 23 Sep 2009 22:15:29 GMT" to a python time-structure. ...

what is setup.py?

Can anyone please explain, what is 'setup.py' and how can it be configured or used? ...

PyQt4 Highlighting

Hi, I'm trying to add some syntax highlighting to a text editor in PyQt4. I've found an example in the documentation which works find when compiled from C++ but when i convert it to Python/PyQt it no longer works. The part of the code that fails (no longer highlights anything) is: def highlightCurrentLine(self): extraSelections =...

regex for triple quote

What regex will find the triple quote comments (possibly multi-line) in a Python source code? ...

What is the Python equivalent of application & session scope variables?

Recently started on python, wondered what the equivalent object was for storing session & application scope data? I'm using Google App Engine too so if it has any extra features (can't seem to find any immediate references myself) that would be useful ...

how can I link against libpython.a such that later the runtime linker can find all the simbols in libpython.a?

In a sequel question to this question, my corporate environment lacks the libpython2.6.so shared object but has the libpython2.6.a file. Is there a way that I can compile in libpython2.6.a while retaining the symbols in libpython2.6.a such that dynamic libraries can find these symbols at runtime? My current compile with the static libr...

Why is host aborting connection?

I'm teaching myself Python networking, and I recalled that back when I was teaching myself threading, I came across this page, so I copied the scripts, updated them for Python 3.1.1 and ran them. They worked perfectly. Then I made a few modifications. My goal is to do something simple: The client pickles an integer and sends it to t...

select_related does not join columns marked with nulll=True

Hi All! I have a Django model - class NoticedUser(models.Model): user = models.ForeignKey(User, null=False) text = models.CharField(max_length=255, null=True) photo = models.ForeignKey(Photo, null=True, blank=True) article = models.ForeignKey(Article, null=True, blank=True) date = models.DateTimeField(default=dateti...

open source data mining/text analysis tools in python

I have a database full of reviews of various products. My task is to perform various calculation and "create" another "database/xml-export" with aggregated data. I am thinking of writing command line programs in python to do that. But I know someone have done this before and I know that there is some open source python solution or simila...

Django ORM - assigning a raw value to DecimalField

EDIT!!! - The casting of the value to a string seems to work fine when I create a new object, but when I try to edit an existing object, it does not allow it. So I have a decimal field in one of my models of Decimal(3,2) When I query up all these objects and try to set this field fieldName = 0.85 OR fieldName = .85 It will throw a ...

How to create a hardlink on attached Volumes on Mac?

os.link is not working for the attached Volumes on Mac. ~ $ python Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.link("/Volumes/ARCHANA/JULY 09/PRAMANPATRA.doc", "/Volumes/ARCHANA/temp")...

django view function code runs after return

Hello, I have a django view that looks like... def add_user(request): if User.objects.get(username__exact = request.POST['username']): context = { 'message': "Username already taken"} return render_to_response("mytemplate.html", context, RequestContext(request)) newUser = User(username="fre...

Writing unicode strings via sys.stdout in Python

Assume for a moment that one cannot use print (and thus enjoy the benefit of automatic encoding detection). So that leaves us with sys.stdout. However, sys.stdout is so dumb as to not do any sensible encoding. Now one reads the Python wiki page PrintFails and goes to try out the following code: $ python -c 'import sys, codecs, locale; ...

python multiprocessing manager & composite pattern sharing

I'm trying to share a composite structure through a multiprocessing manager but I felt in trouble with a "RuntimeError: maximum recursion depth exceeded" when trying to use just one of the Composite class methods. The class is token from code.activestate and tested by me before inclusion into the manager. When retrieving the class into...

Raising ValidationError from django model's save method?

I need to raise an exception in a model's save method. I'm hoping that an exception exists that will be caught by any django ModelForm that uses this model including the admin forms. I tried raising django.forms.ValidationError, but this seems to be uncaught by the admin forms. The model makes a remote procedure call at save time, and ...

Ghostscript on Google App Engine?

Hello, Is it possible to call ghostscript on an App Engine project? I'd like to be able to perform some document conversion using gs (pdf to tiff in particular), and I am not seeing any specific documentation that either rules out this possibility or states how to pull it off. Thanks! Shaheeb R. ...

Django Admin: Ordering of ForeignKey and ManyToManyField relations referencing User

Hello, I have an application that makes use of Django's UserProfile to extend the built-in Django User model. Looks a bit like: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) # Local Stuff image_url_s = models.CharField(max_length=128, blank=True) image_url_m = models.CharField(max_length=...

Python Weather API

How do I get my weather in a Python program? ...