I'm building a Python/Pylons webapp that has been served by single server so far, now I want to investigate how it would scale among several servers with some kind of load balancer in front.
The main concern is server-side state, of course. It includes user session data, user uploaded data (pictures and the like), and cache. I want app...
To illustrate, I start with a list of 2-tuples:
import itertools
import operator
raw = [(1, "one"),
(2, "two"),
(1, "one"),
(3, "three"),
(2, "two")]
for key, grp in itertools.groupby(raw, key=lambda item: item[0]):
print key, list(grp).pop()[1]
yields:
1 one
2 two
1 one
3 three
2 two
In an attempt...
Hello,
I need to read a plist file and search for a string, then add a new line of text on the next line. I can't imagine it will take much to do this. However the plist is in binary format so not exactly sure how to deal with that.
Thanks in advance,
Aaron
#Convert plist to XML
os.system('plutil -convert xml1 com.apple.iChat.Jabber...
I need to do one thing if args is integer and ather thing if args is string.
How can i chack type? Example:
def handle(self, *args, **options):
if not args:
do_something()
elif args is integer:
do_some_ather_thing:
elif args is string:
do_totally_different_thing()
...
I'm a Python programmer with experience using the json module. I've just meet CouchDB and seems very interesting.
I wonder know if JSON data structures can be directly saved as a CouchDB document.
Thanks,
...
I have a dictionary in Python where the keys are pathnames. For example:
dict["/A"] = 0
dict["/A/B"] = 1
dict["/A/C"] = 1
dict["/X"] = 10
dict["/X/Y"] = 11
I was wondering, what's a good way to print all "subpaths" given any key.
For example, given a function called "print_dict_path" that does this, something like
print_dict_path("...
Given an arbitrary python object, what's the best way to determine whether it is a number? Here is is defined as acts like a number in certain circumstances.
For example, say you are writing a vector class. If given another vector, you want to find the dot product. If given a scalar, you want to scale the whole vector.
Checking if some...
I'm trying to redirect users to custom url "/gallery/(username)/" after successfully logging in. It currently redirects to the default "/account/profile/" While I know what I can override the redirect url in my settings.py, my url is dynamic thus it will not work.
Documentation states that I need to use the "next" parameter and contex...
I'm trying to read and handle a web-page in Python which has lines like the following in it:
<div class="or_q_tagcloud" id="tag1611"></div></td></tr><tr><td class="or_q_artist"><a title="[Artist916]" href="http://rateyourmusic.com/artist/ac_dc" class="artist">AC/DC</a></td><td class="or_q_album"><a title="[Album374717]" hr...
Hello:
I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.
What is the best way to make a plug in to this module? My thoughts are:
Provide the functionalities as command line utilities a...
I've been trying for hours to get this simple script working, but nothing I do seems to help. It's a slight modification of the most basic animated plot sample code from the Matplotlib website, that should just show a few frames of noise (I have the same issue with the unmodified code from their website BTW).
On my computer with the TkA...
I'm working on a form using wxPython where I want want listctrl's list of values to change based on the selection of another listctrl. To do this, I'm using methods linked to the controlling object's EVT_LIST_ITEM_SELECTED and EVT_LIST_ITEM_DESELECTED events to call Publisher.sendMessage. The control to be changed has a method that is ...
I am using Sqlite3 with Flask microframework, but this question concerns only the Sqlite side of things..
Here is a snippet of the code:
g.db.execute('INSERT INTO downloads (name, owner, mimetype) VALUES (?, ?, ?)', [name, owner, mimetype])
file_entry = query_db('SELECT last_insert_rowid()')
g.db.commit()
The downloads table has anot...
If I execute the following Python 3.1 program, I see only � instead of the correct characters in my browser. The file itself is UTF-8 encoded and the same encoding is sent with the response.
from wsgiref.simple_server import make_server
page = "<html><body>äöü€ßÄÖÜ</body></html>"
def application(environ, start_response):
start_res...
I have been having a problem where after my mongodb connection to mongohq via pymongo goes idle for awhile (no queries), it will timeout. This is fine, but the connection the database is only created when the Django app is started up. It seems like it is reconnecting fine, but it needs to reauthenticate then. When the connection has died...
Possible Duplicate:
call to matlab function in a python prorgam
hi
I am trying to run a function I wrote in matlab from a python script.
lets say that the maltab program is
function [ret1,ret2] = TestFunction (input1,input2)
ret1=input1-input2
ret2=input1+input2
end
and I want to run it from a python program:
a=5
b=6
here I...
I've got a Python webservice using SOAPpy. The webservice server is structured as shown below:
class myClass:
def hello():
return 'world'
if __name__ == "__main__":
server = SOAPServer( ( 'localhost', 8888 ) )
myObject = myClass()
namespace = 'whatever::namespace'
server.registerObject( myObject, namespace )
server.ser...
I have a python script that connects to a local MySQL db. I know it is connecting correctly because I can do this and get the proper results:
cursor.execute("SELECT * FROM reel")
But when I try to do any insert statements it just does nothing. No error messages, no exceptions. Nothing shows up in the database when I check it from sqlyo...
Hello,
I wonder what you can use as a key_name?
I do a lot of queries on non-ascii unicode characters, I wonder if I can use these as key names to speed up the queries.
Thanks!
...
ok so I have the following problem i`ve looked around but I cant find a solution ...
lets say I have the following forms.py
from django import forms
class LoginForm(forms.Form):
_username = forms.CharField()
_password = forms.CharField()
and in views.py I have
def index(request):
if request.method == 'POST':
fo...