Say I use raw_input like this:
code = raw_input("Please enter your three-letter code or a blank line to quit: ") under if __name__=="__main__":
How can I let it repeat multiple times rather than just once every time I run the program?
Another question is to write what code can satisfy the condition "or a blank line to quit (the program)"...
Hi Friends,
Please provide me a sample explaining how to load & call a funtions in c++ dll using Python?
I found some articles saying we can use "ctypes" to load and call a function in DLL using Python. But i am not able to find a working sample?
It would be great if anyone provide me an sample of how to do it.
...
I am trying to figure out a regular expression which matches any string which doesn't start with mpeg. A generalization of this is matching any string which doesn't start with a given regular expression.
I tried something like as follows:
[^m][^p][^e][^g].*
The problem with this is that it requires at least 4 characters to be present...
Say I have three dicts d1={1:2,3:4}, d2={5:6,7:9}, d3={10:8,13:22}, how do I create a new d4 that combines these three dictionaries. i.e d4={1:2,3:4,5:6,7:9,10:8,13:22}?
...
This is Common task In PHP and other programming languages.I moved from PHP developer.
I want to make sure with this collections.
Anyone have who good in python please help me to understand clearly .
This is my collections from PHP code.
<?php
$php = array(1,2,3,4,5,6,7,8,9,10);
for ($i = 0; $i < 10 ; $i ++)
echo $php[$i]."<br>";
?>
=...
Just installed Django (with easy_install) and created a project, but can't get mysql to work.
python manage.py syncdb throws this error:
.....
File "/Library/Python/2.6/site-packages/Django-1.1.1-py2.6.egg/django/db/backends/mysql/base.py", line 13, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)...
In most programming environments it's clear how the code is distributed into several parts and how everything interacts. In Python I seem to be completely lost.
How should the layout of a Python application look?
Currently I have:
setup.py
application_name/
__main__.py
__init__.py
views/
controllers/
model/
r...
I have a web server based on paste.httpserver as an adapater between HTTP and WSGI. When I do performance measurements with httperf, I can do over 1,000 requests per second if I start a new request each time using --num-conn. If I instead reuse the connection using --num-call then I get about 11 requests per second, 1/100th of the speed....
Here is my Sudoku Solver written in python language, When I run this program there seems to be a problem with in Update function and Solve function.
No matter how much time I look over and move the codes around, I seem to have no luck
Can anyone Help me?
import copy
def display (A):
if A:
for i in range (9):
...
I have to run a legacy Zope2 website and have some grievance with it. The biggest issue is that, occasionally, it just locks up, running at 100% CPU load and not answering to requests anymore. While the problem isn't reproducible on a regular basis, one page containing 3 dynamic graphs triggers it sometimes, so I suspect some kind of rac...
I have the following code:
print img.size
print 10 * img.size
this will print
(70, 70)
(70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70)
while I'd like it to print
(700, 700)
Is any way there to do this without having to write
print (10 * img.size[0], 10 * img.size[1])
PS: img.size is a PIL imag...
I am new to Python and would like to know if someone would kindly convert an example of a fairly simple Perl script to Python?
The script takes 2 files and outputs only unique lines from the second file by comparing hash keys. It also outputs duplicate lines to a file. I have found that this method of deduping is extremely fast with Pe...
I'm trying to use fancy indexing instead of looping to speed up a function in Numpy. To the best of my knowledge, I've implemented the fancy indexing version correctly. The problem is that the two functions (loop and fancy-indexed) do not return the same result. I'm not sure why. It's worth pointing out that the functions do return the s...
[(u'we', 'PRP'), (u'saw', 'VBD'), (u'you', 'PRP'), (u'bruh', 'VBP'), (u'.', '.')]
I want to order this alphabetically, by "PRP, VBD, PRP, and VBP"
It's not the traditional sort, right?
...
i have string
date = "11/28/2009"
hour = "23"
minutes = "59"
seconds = "00"
how can i convert to datetime object and store it in datastore?
...
I am trying to parse and submit a form on a website using mechanize, but it appears that the built-in form parser cannot detect the form and its elements. I suspect that it is choking on poorly formed HTML, and I'd like to try pre-parsing it with a parser better designed to handle bad HTML (say lxml or BeautifulSoup) and then feeding the...
Hello, how can I access Firefox proxy settings from Python Webdriver and change them to make Firefox use modified proxy settings without needing to restart it?
...
I'm writing a python program that deals with a fair amount of strings/files. My problem is that I'm going to be presented with a fairly short piece of text, and I'm going to need to search it for instances of a fairly broad range of words/phrases.
I'm thinking I'll need to compile regular expressions as a way of matching these words/phr...
I want to distribute a Python application to windows users who don't have Python or the correct Python version.
I have tried py2exe conversion but my Python program is really complex and involve code import on the fly by xmlrpc process so it is not suitable for py2exe.
The complete Python folder takes around 80MB but this includes docs...
Can you help me with plotting data from postgresql database (postgis) in python with matplotlib? There are .shp polygons in that database. I need to create simple graphic interface to show those polygons. (cant use any other software, only python and matplotlib). Thank you!
...