I need to throw ValidationError containing anchor.
if not profile.activated():
raise ValidationError('Your profile is not activated. <a href="{% url resend_activation_key %}">Resend activation key</a>.')
What I need to modify to make this work?
...
My config file is really just a big python dict, but I have many config files to run different experiments and I want to 'import' a different one based on a command line option. Instinctively I want to do import ConfigFileName where ConfigFileName is a string with the config file's python package name in it... but that doesn't work.
An...
I'm writing a simple dual timer in Python. (I'm running Linux, and this should only need to run on my system.) The idea is that the script has two separate timers, one of which is running at any one time. The user should be able to press a button to either switch which timer is running, or pause both. Currently, the test script looks lik...
I have this Python code that I found online and would like to know how to translate it to Java. My question is not about the algorithm but how to handle the function's arguments.
Here is the code:
def ternarySearch(f, left, right, absolutePrecision):
#left and right are the current bounds; the maximum is between them
if (right...
Hello,
I am runninig test's with Python Unittest. I am running tests but I want to do negative testing and I would like to test if a function throw's an exception, it passes but if no exception is thrown the test fail's. The script I have is:
try:
result = self.client.service.GetStreamUri(self.stream, self.token)
se...
In NumPy functions, there are often initial lines that do checking of variable types, forcing them to be certain types, etc. Can someone explain the point of these lines in scipy.signal.square? What does subtracting a value from itself do?
t,w = asarray(t), asarray(duty)
w = asarray(w + (t-t))
t = asarray(t + (w-w))
source
...
I have two models, authors and articles:
class Author(models.Model):
name = models.CharField('name', max_length=100)
class Article(models.Model)
title = models.CharField('title', max_length=100)
pubdate = models.DateTimeField('publication date')
authors = models.ManyToManyField(Author)
Now I want to select all authors...
Say that python package A requires B, C and D;
is there a way to list A B C D without loading them ?
Requires in the metadata (yolk -M A) are often incomplete, grr.
One can download A.tar / A.egg, then look through A/setup.py,
but some of those are pretty gory.
(I'd have thought that getting at least first-level dependencies could be m...
Thanks for the help in advance. I am puzzled that the same code works for python 2.6 but not 2.5. Here is the code
import cgi, urllib, urlparse, urllib2
url='https://graph.facebook.com'
req=urllib2.Request(url=url)
p=urllib2.urlopen(req)
response = cgi.parse_qs(p.read())
And here is the exception I got
Traceback (most recent call l...
Hi,
I'm using cx_Freeze to freeze my python program. On running cx_Freeze, a bunch of PYD files are created, a whole bunch of PYC files are put into a archive named library.zip and a few DLL files are there too.
Could someone tell me the difference between the PYC and the PYD files?
What's the reason for the PYD files not in the librar...
Here is my code:
#Make the SOAP connection
url = "https://api.channeladvisor.com/ChannelAdvisorAPI/v1/InventoryService.asmx?WSDL"
headers = {'Content-Type': 'text/xml; charset=utf-8'}
ca_client_inventory = Client(url, location="https://api.channeladvisor.com/ChannelAdvisorAPI/v1/InventoryService.asmx", headers=headers)
#Make the SOAP he...
We have a web application that takes file uploads for some parts. The file uploads aren't terribly big (mostly word documents and such), but they're much larger than your typical web request and they tend to tie up our threaded servers (zope 2 servers running behind an Apache proxy).
I'm mostly in the brainstorming phase right now and...
I have a c function being called from python. Python gives the function an integer, but I would like to use it as another data type in C. I am currently using
PyArg_ParseTuple (args, "i", &value) and then manually doing a cast on value.
Is there a way to do this cast through PyArg?
...
I am currently learning PHP and want to learn about OOP.
I know Python is a well-organized and is all OOP, so would learning Python be a wise choose to learn OOP?
The thing is I am more towards web development then just general programming, and I know Python is just a general purpose language, but there is Django.
So how should I g...
I've got a setup based on the post here, and it works perfectly. Adding more languages to the mix, it recognises them fine, except for Korean (ko) and Hindi (hi). Chinese/Japanese/Hebrew are all fine, so nothing to do with encodings/charsets I don't think.
Taking a look into the django code inside the app-engine SDK, I notice that all t...
I'm trying to write a function that backs up a directory with files of different permission to an archive on Windows XP. I'm using the tarfile module to tar the directory. Currently as soon as the program encounters a file that does not have read permissions, it stops giving the error: IOError: [Errno 13] Permission denied: 'path to fi...
I am trying to write a Python script that will access and modify the active Excel workbook using the Excel COM interface. However, I am having difficulty getting this to work when there are multiple Excel instances running. For example, the code
import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
print(xl.ActiveWo...
There are several utilities — all with different procedures, limitations, and target operating systems — for getting a Python package and all of its dependencies and turning them into a single binary program that is easy to ship to customers:
http://wiki.python.org/moin/Freeze
http://www.pyinstaller.org/
http://www.py2exe.org/
http://s...
Hi,
This is something similar to what's posted here: http://stackoverflow.com/questions/312549/no-module-named-django-core
To reiterate, I'm getting this error on running "django-admin.py startproject mysite"(without the double quotes):
C:\Documents and Settings\fixavier\Desktop>django-admin.py startproject mysite
Traceback (most recen...
I am reading the Django localization documentation:http://docs.djangoproject.com/en/dev/topics/i18n/localization/
Of course, where the user is from determines what "message file" to use.
How do I determine where the user is from and what to use? Does it do it automatically?
...