Hi I'm sitting in a Greyhound Bus with Wifi and want to connect a second Device to the Network. But I have to accept an onscreen contract and the device does not have a browser.
To accept the contract the following form has to be accepted. The device has no CURL but all the standard python 2.6. libraries.
<form method="POST" name="wif...
I use 'property' to ensure that changes to an objects instance variables are wrapped by methods where I need to.
What about when an instance has an variable that logically should not be changed? Eg, if I'm making a class for a Process, each Process instance should have a pid attribute that will frequently be accessed but should not be ...
I'm trying to convert a Perl script to python, and it uses quite a few different packs. I've been able to figure out the lettering differences in the "templates" for each one, but I'm having an issue with understanding how to handle Perl's lack of length declaration.
example:
pack('Nc*',$some_integer,$long_array_of_integers);
I don't...
Hello,
I have been asked to publish a complete book online similar way Google Books does? i.e. it's viewable and printable but not download-able.
Is the process is basically "high quality scanning"? are there any open source solution to "mass generation" of "watermark" on those high quality images. Suppose you have an original image. ...
Suppose I have a AJAX function:
function callpage{
$.ajax({
method:"get",
url:"/abc/",
data:"x="+3
beforeSend:function() {},
success:function(html){
IF HTTPRESPONSE = "1" , ALERT SUCCESS!
}
});
return false;
}
}
When my "View" executes in Django, I want to return HttpResponse('1') or '0'.
How ca...
I'm just starting to learn Python and Django and an unable to get the most basic app working. I've setup Python, added python to the Path environment variable, installed Django using install.py script.
I created an app by running the command
django-admin.py startproject my_project
updated the settings.py file for a database
DATABAS...
I like IPython a lot for working with the python interpreter. However, I continually find myself typing exit to exit, and get prompted "Type exit() to exit."
I know I can type Ctrl-D to exit, but is there a way I can type exit without parentheses and get IPython to exit?
Update: Thanks to nosklo, this can be easily done by adding the...
It sounds like an odd one but it's a really simple idea. I'm trying to make a simple Flickr for a website I'm building. This specific problem comes when I want to show a single photo (from my Photo model) on the page but I also want to show the image before it in the stream and the image after it.
If I were only sorting these streams by...
I have a string like this:
"a word {{bla|123|456}} another {{bli|789|123}} some more text {{blu|789}} and more".
I would like to get this as an output:
(("bla", 123, 456), ("bli", 789, 123), ("blu", 789))
I haven't been able to find the proper python regex to achieve that.
...
I have some a list comprehension in Python in which each iteration can throw an exception.
For instance, if I have:
eggs = (1,3,0,3,2)
[1/egg for egg in eggs]
I'll get a ZeroDivisionError exception in the 3rd element.
How can I handle this exception and continue execution of the list comprehension?
The only way I can think of is...
Perl has the -c switch to compile the code without running it. This is convenient for debugging compile errors in Perl.
Does Python have a similar switch?
...
I need to write a few programs for a project I'm currently working on and I'm very much used to Visual Studio 2008 and I do not mind programming in Python but I need to have a comfortable GUI programming ontop of the language itself, and it has to be well integrated and fast. I know that's a lot to ask for but is there any such thing out...
I still can't seem to get a "correct" answer to this question.
Essentially I want to create a JSON-RPC server with the following functions
string subcribe_to_feed( callback )
string get_information( params )
The client is an iPhone application, and the server should be done in Twisted (if possible)
The client should be able to do so...
I am making a small app that lets users vote items either up or down. I'm using Django (and new to it!).
I am just wondering, what is the best way to present the upvote link to the user. As a link, button or something else?
I have already done something like this in php with a different framework but I'm not sure if I can do it the sam...
thechan = Score.objects.filter(content=44)[0:1]
thechan[0].custom_score = 2
thechan[0].save()
I do print statements, and it shows everything fine. However, it's not SAVING!
I go into my database, and I run a simple SELECT statement..and it's not changed!
select custom_score FROM music_score where content_id = 44;
...
My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython.
I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use less encumbered data structur...
Is there a better way to read lines two at a time from a file in python than:
with open(fn) as f:
for line in f:
try:
line2 = f.next()
except StopIteration:
line2 = ''
print line, line2 # or something more interesting
I'm in 2.5.4. Anything different in newer versions?
EDIT: a dele...
The runtime keeps telling me:
expected an indented block
But I don't want write nothing inside my except block, I just want it to catch and swallow the exception.
...
I want to detect pressing the "snapshot" button on the top of a webcam in linux. The button has this entry in /dev:
/dev/input/by-id/usb-PixArt_Imaging_Inc._USB2.0_UVC_VGA-event-if00
I am using the "rel" wrapper, at the moment, because it handles exceptions better. Before the following code executes, self.s.cam_btn is assigned the /d...
In Javascript it would be:
var newObject = { 'propertyName' : 'propertyValue' };
How to do it in Python?
...