Is it possible to get request.user data in a form class? I want to clean an email address to make sure that it's unique, but if it's the current users email address then it should pass.
This is what I currently have which works great for creating new users, but if I want to edit a user I run into the problem of their email not validati...
The official documentation for TemporaryFile reads:
The mode parameter defaults to 'w+b'
so that the file created can be read
and written without being closed.
Yet, the below code does not work as expected:
import tempfile
def play_with_fd():
with tempfile.TemporaryFile() as f:
f.write('test data\n')
f.wri...
I'm trying to extract a bunch of lines from a CSV file and write them into another, but I'm having some problems.
import csv
f = open("my_csv_file.csv", "r")
r = csv.DictReader(f, delimiter=',')
fieldnames = r.fieldnames
target = open("united.csv", 'w')
w = csv.DictWriter(united, fieldnames=fieldnames)
while True:
try:
row = r.ne...
I'm trying to use Python's easygui module to select a file and then insert it's name into a program I wrote (see code below). So I want to insert filename 1 and 2 where it says insert filename1, etc.. Any help would be greatly appreciated. Thanks!
import easygui
import csv
msg='none'
title='select a 90m distance csv file'
filetypes=...
I have a few already but wanted to merge them into one public domain oauth code library for twitter, facebook, friendfeed (and let other developers improve the library for their preferred connections).
I'm having a tough time just debugging mashing friendfeed and twitters oauth into one friendly python program running on the Google App ...
Hi,
I need to calculate the inverse of complementary error function (erfc^(1))for a problem.
I was looking into python tools for it and many threads said Enthought has most of the
math tools needed, so I downloaded and installed in my local user account. But I am not
very sure about how to use it?
Any ideas?
Thanks
...
I've created a basic menu class that looks like this:
class Menu:
def __init__(self, title, body):
self.title = title
self.body = body
def display(self):
#print the menu to the screen
What I want to do is format the title and the body so they fit inside premade boxes almost. Where no matter what I pass...
Here's an example:
from django import forms
class ArticleForm(forms.Form):
title = forms.CharField()
pub_date = forms.DateField()
from django.forms.formsets import formset_factory
ArticleFormSet = formset_factory(ArticleForm)
formset = ArticleFormSet(initial=my_data)
So 'my_data' in the example is the data I want to form t...
I'm trying to write a lambda-expression that calls itself, but i can't seem to find any syntax for that, or even if it's possible.
Essentially what I wanted to transfer the following function into the following lambda expression: (I realize it's a silly application, it just adds, but I'm exploring what I can do with lambda-expressions i...
I'm trying to provide integration to my django application from subversion through the post commit hook.
I have a django test case (a subclass of unittest.TestCase) that (a) inserts a couple of records into a table, (b) spawns an svn commit, (c) svn commit runs a hook that uses my django model to look up info.
I'm using an sqlite3 db. ...
Recently i asked a question regarding an error in apache/mod_wsgi recognizing the python script directory.
The community kindly answered the question resulting in a successful installation. Now I have a different error, the server daemon (well, technically is a windows service, I say tomato you say...) doesn't find any of the models, her...
How do I write my application so it'll live in the system tray on Linux? In fact, just like CheckGmail.
As with CheckGmail, I'd also like some sort of popup box to appear when I hover the tray icon.
Is there an API, class or something for doing this? All I'm able to find seems to be for Windows.
If I have to be language specific, then...
Does Django have anything equivalent to the New Relic RPM performance monitoring app for Rails (http://www.newrelic.com/)?
Looking to do an app in Django, but would really like to be able to use something like New Relic for monitoring performance.
...
I'm making some pretty big graphs, and the whitespace in the border is taking up a lot of pixels that would be better used by data. It seems that the border grows as the graph grows.
Here are the guts of my graphing code:
import matplotlib
from pylab import figure
fig = figure()
ax = fig.add_subplot(111...
I have to work with some image files. They are named as .png and .jpg, but I tried 3 different image viewers, and none of them could open the files. I found out that the first 8 bytes of these files were CF10rUrm, and DROID told me it was a JTIP (JPEG Tiled Image Pyramid).
I need to use these from Python. Does anybody know of any way to...
I have a site running in Django. Frontend is lighttpd and is using fcgi to host django.
I start my fcgi processes as follows:
python2.6 /<snip>/manage.py runfcgi maxrequests=10 host=127.0.0.1 port=8000 pidfile=django.pid
For logging, I have a RotatingFileHandler defined as follows:
file_handler = RotatingFileHandler(filename, maxByt...
Hi--I'm fairly new to python and following along with part 4 of the tutorial for the Django framework here. I'm trying to implement generic views for the polls app--my code seems correct (as far as I can tell), but when I try to vote, I get a NoReverseMatch Exception that states:
Reverse for 'polls/poll_results' with arguments '(1L,...
I'm trying to use python's re.sub function to replace some text.
>>> import re
>>> text = "<hi type=\"italic\"> the></hi>"
>>> pat_error = re.compile(">(\s*\w*)*>")
>>> pat_error.search(text)
<_sre.SRE_Match object at 0xb7a3fea0>
>>> re.sub(pat_error, ">\1", text)
'<hi type="italic">\x01</hi>'
Afterwards the value of text should be
...
Why eval function doesn't work with \r\n but with \n. for example
eval("for i in range(5):\r\n print 'hello'") doesn't work
eval("for i in range(5):\n print 'hello'") works
I know there is not a problem cause using replace("\r","") is corrected, but someone knows why happens?
--Edit--
Oh! sorry , exactly, I meant exec. Carriage r...
From within a Python application, how can I get the total amount of RAM of the system and how much of it is currently free, in a cross-platform way?
Ideally, the amount of free RAM should consider only physical memory that can actually be allocated to the Python process.
...