I have a Django project that contains two applications App1 and App2
I have configured two databases DB1 and DB2
when I use python manage.py syncdb the tables corresponding to model of the two application are created in the first database
How can I configure Django to make the model of the first application goes to the fir...
I known python can use pipe to communicate between two process of py.
But, data and functions of this method are not clear.
I like .net remoting better.
So, can python realize that approach?
...
I'm streaming a very large collection through a script and am currently using ifilter in a simple call to reject certain values, i.e.:
ifilter(lambda x: x in accept_list, read_records(filename))
That's one predicate, but now it's occurred to me I should add another, and I might want to add others in the future. The straightforward way...
How can I create another dictionary using the keys of another dictionary, and an array of values?
I thought about doing this:
zipped = zip(theExistingDict.keys(), arrayOfValues)
myNewDict = dict(zipped)
However, this doesn't quite work, each value from arrayOfValues are paired with an arbitrary key in the resulting dictionary. I don'...
I'm going to throw out some pseudocode. Then explain what I want, because I am not sure how to otherwise.
File_A
class Panel_A(wx.Panel)
def __init__(self):
button_a = wx.Button(parent=self)
def onButton(self, event):
pass to list view
File_B
class Panel_B(wx.panel):
def __init__(self):
listview_a =...
Say I have an empty list myNames = []
How can I open a file with names on each line and read in each name into the list?
like
names.txt
dave
jeff
ted
myNames = [dave,jeff,ted]
...
I am consuming a webservice (written in java) - that basically returns a byte[] array (the SOAP equivalent is base64 encoded binary data).
I am using the python suds library and the following code works for me on my mac (and on cygwin under windows), but the decoding does not work on vanilla windows (python 2.6.5). I am primarily a jav...
I'm working with a (Python-flavored) regular expression to recognize common and idiosyncratic forms and abbreviations of scripture references. Given the following verbose snippet:
>>> cp = re.compile(ur"""
(?:(
# Numbered books
(?:(?:Third|Thir|Thi|III|3rd|Th|3)\ ?
(?:John|Joh|Jhn|Jo|Jn|Jn|J))
# O...
I'm just getting back into Project Euler and have lost my account and solutions, so I'm back on problem 7. However, my code doesn't work. It seems fairly elementary to me, can someone help me debug my (short) script?
Should find the 10001st Prime.
#!/usr/bin/env python
#encoding: utf-8
"""
P7.py
Created by Andrew Levenson on 2010-06-2...
It's too hot & I'm probably being retarded.
>>> "/1/2/3/".split("/")
['', '1', '2', '3','']
Whats with the empty elements at the start and end?
Edit: Thanks all, im putting this down to heat induced brain failure. The docs aren't quite the clearest though, from http://docs.python.org/library/stdtypes.html
"Return a list of the words...
Hello
I am looking for a list functionnality in Python.
I am doing this :
abcd = [1, 2, 3, 4]
try:
item = list[5]
except:
item = 0
How can I make it looks like :
item = abcd.get(5, 0)
Thanks for your help
...
I find this project: http://code.google.com/p/standalonewebsocketserver/ for a websocket server, but i need implement a client of websocket in python, more exactly i need receive some commands from xmpp in my websocket server
...
Hi all,
I encountered a problem with the scope variables have when IPython is invoked at the end of a python script.
All functions I call in the script itself can modify variables, which will subsequently be used by other functions.
If I call the same functions in ipython, the scripted ones can access the changed variables but variables...
I want to run a script to check whether certain files in my Dropbox folder have changed. I am currently using os.path.getmtime() to check that the modified time is in some window of time.time(). The problem is that if I modify a file in my Dropbox folder from a different computer than where the script is set to run, the modified time doe...
this is the code in my models file:
from django.db import models
class Studio(models.Model):
.....
.....
metroimage = models.ImageField(upload_to='images', blank=True)
this is the code on the template file:
{% for place in studio %}
.....
.....
<img class="metro" src="{{ place...
Hi,
I have a specific question regarding the usage of profiler. I am new to python programming
I am trying to profile a function which I want to invoke as a class method, something like this
import profile
class Class:
def doSomething():
do here ..
def callMethod():
self.doSomething()
instead of this I want ...
I am just a beginner in python. I have document score= {1:0.98876, 8:0.12245, 13:0.57689} which is stored in dictionary. The keys are corresponding to a series of document id and the values are corresponding to the score for each document id. How do I rank the document based on the scores?
inverse=[(value, key) for key, value in score.i...
I've noticed that importing a module will import its functions and methods, and the functions and methods of those as well. Is there a set rule for how many levels down python will import when you import an upper-level module?
edit
sorry, I think I've been misunderstood by the answers so far responding about multiple imports of some d...
I'm lucky enough to have full control over the architecture of my company's app, and I've decided to scrap our prototype written in Ruby/Rails and start afresh in Python. This is for a few reasons: I want to learn Python, I prefer the syntax and I've basically said "F**k it, let's do it."
So, baring in mind this is going to be a pretty ...
Here is a the code I have so far:
from ConfigParser import *
import MySQLdb
configuration = ConfigParser()
configuration.read('someconfigfile.conf')
db = MySQLdb.connect(
host = configuration.get('DATABASE', 'MYSQL_HOST'),
user = configuration.get('DATABASE', 'MYSQL_USER'),
passwd = configuration.get('DATABASE', 'MYSQL_...