I have a view that accepts a form submission and updates a model.
After updating the model, I want to redirect to another page and I want a message such as "Field X successfully updated" to appear on this page.
How can I "pass" this message to the other page? HttpResponseRedirect only accepts a url. I've seen this done before on othe...
I have a project where i'm trying to use weakrefs with callbacks, and I don't understand what I'm doing wrong. I have created simplified test that shows the exact behavior i'm confused with.
Why is it that in this test test_a works as expected, but the weakref for self.MyCallbackB disappears between the class initialization and calling...
When using os.listdir method I need to tell which item in the resulting list is a directory or just a file.
I've faced a problem when I had to go through all the directories in this list, and then add a file in every single directory.
Is there a way to go through this list and remove all files from it? If it isn't possible to do with ...
Hi there,
This will surely be an easy one but it is really bugging me.
I have a script that reads in a webpage and uses BeutifulSoup to parse it. From the soup I extract all the links as my final goal is to print out the link.contents.
All off the text that I am parsing is ASCII. I know that python treats strings as unicode, and I am...
From the website http://www.mobilepythonbook.org/ I found the following example of bluetooth sockets: BT chat example
Here in function chat_server() the bind method accepts a tuple with two elements. The first one has been used as a null string. What does it signify?
Which node will act as master in the Bluetooth, the one that starts c...
Hello
I have a simple python code that searches a files for a string "path=c:\path" ( "c:\path" is the part that can change and returns a text after "path=". Current code sketch is:
def findPath( i_file) :
lines = open( i_file ).readlines()
for line in lines :
if line.startswith( "Path=" ) :
return # what to do here in or...
In my application I have to maintain some global application state and global application wide methods like currently connected users, total number of answers, create an application config file etc. There are two options:
Make a separate appstate.py file with global variables with functions over them. It looks fine initially but it see...
I understand that there are big differences in data-store, but surely since django is bundled and it abstracts data-store away from Satchmo, something can be done?
Truth is that I am not a Python guy, been mostly Java/PHP thus far, but I am willing to learn.
Plus, if this is not possible today, lets band together and form a new Open So...
Is there a way to get functionality similar to mkdir -p on the shell... from within python. I am looking for a solution other than a system call. I am sure the code is less than 20 lines... really I am wondering if someone has already written it?
...
When I run this:
import urllib
feed = urllib.urlopen("http://www.yahoo.com")
print feed
I get this output in the interactive window (PythonWin):
<addinfourl at 48213968 whose fp = <socket._fileobject object at 0x02E14070>>
I'm expecting to get the source of the above URL. I know this has worked on other computers (like the ones ...
Please tell me which features you wish your current Python debugger had. I'm creating a new Python IDE/debugger and am looking forward to challenging requests!
...
Hey guys,
Consider the following Python code:
30 url = "http://www.google.com/search?hl=en&safe=off&q=Monkey"
31 url_object = urllib.request.urlopen(url);
32 print(url_object.read());
When this is run, an Exception is thrown:
File "/usr/local/lib/python3.0/urllib/request.py", line 485, in http_error_default
raise HTT...
What is the difference between IronPython and BOO? Is there a need for 2 Python-like languages?
...
I'm making a simple web-based, turn-based game and am trying to determine what modules exist out there to help me on this task.
Here's the web app I'm looking to build:
User visits the homepage, clicks on a "play game" link
This takes the user to a "game room" where he either joins someone else who has been waiting for a partner to p...
I'm downloading a huge set of files with following code in a loop:
try:
urllib.urlretrieve(url2download, destination_on_local_filesystem)
except KeyboardInterrupt:
break
except:
print "Timed-out or got some other exception: "+url2download
If the server times-out on URL url2download when connection is just initiating, the l...
I do a lot of Python quick simulation stuff and I'm constantly saving (:w) and then running (:!!). I'm wondering, is there a way to combine these actions. Maybe a "save and run" command.
Thanks for your help.
...
I am trying to parse an html page with BeautifulSoup, but it appears that BeautifulSoup doesn't like the html or that page at all. When I run the code below, the method prettify() returns me only the script block of the page (see below). Does anybody has an idea why it happens?
import urllib2
from BeautifulSoup import BeautifulSoup
ur...
I bought a low-end MacBook about a month ago and am finally getting around to configuring it for Python. I've done most of my Python work in Windows up until now, and am finding the choices for OS X a little daunting. It looks like there are at least five options to use for Python development:
"Stock" Apple Python
MacPython
Fink
MacPor...
I want to create a floor plan map of an interior space that has clickable regions. My first thought was to investigate GeoDjango since its the mapping app for Django. But considering the dependencies, the learning curve and overall complexity, I'm concerned that I may be trying to swat a fly with a bazooka.
Should I use GeoDjango for ...
I'm just starting with NumPy so I may be missing some core concepts...
What's the best way to create a NumPy array from a dictionary whose values are lists?
Something like this:
d = { 1: [10,20,30] , 2: [50,60], 3: [100,200,300,400,500] }
Should turn into something like:
data = [
[10,20,30,?,?],
[50,60,?,?,?],
[100,200,300,40...