Suppose I'm creating a class to validate a number, like "Social Security" in US (just as an example of a country-based id). There are some rules to validate this number that comes from an input in a html form in a website.
I thinking about creating a simple class in Python, and a public validate method. This validate returns True or Fal...
So I have a python script that relies on a couple modules. Specifically pexpect and pyinoitify. I know you can compile a python script into a .exe in windows, but is there something relatively equivalent in linux? I don't care about it being a binary, I'd just like to be able to distribute my script without requiring the separate install...
Hey.
I created a new Pylons project, and would like to use Cassandra as my database server. I plan on using Pycassa to be able to use cassandra 0.7beta.
Unfortunately, I don't know where to instantiate the connection to make it available in my application.
The goal would be to :
Create a pool when the application is launched
Get a c...
I have a fairly complex Python object that I need to share between multiple processes. I launch these processes using multiprocessing.Process. When I share an object with multiprocessing.Queue and multiprocessing.Pipe in it, they are shared just fine. But when I try to share an object with other non-multiprocessing-module objects, it see...
After reading this very informative (albeit somewhat argumentative) question I would like to know your experience with programming large projects with Python. Do things become un manageable as the project becomes larger? This concern is one thing that keeps me attached to Java. I would therefore be particularly interested in informed ...
hello all, how to set or create new environment variables in ubuntu(10.04, 64bits), for a python library. I have to configure
PYTHONPATH
library_HOME
library_data
thanks for your help
...
I'm using a function in a card game, to check the value of each card, and see if it is higher than the last card played.
def Valid(card):
prev=pile[len(pile)-1]
cardValue=0
prevValue=0
if card[0]=="J":
cardValue=11
elif card[0]=="Q":
cardValue=12
elif card[0]=="K":
cardValue=13
elif card[0]=="A":
cardValue=14
else:
c...
How could i upload a file to a server without using FieldStorage in python?
...
I'm trying to use a radio button in my modelform but its just outputting nothing when I do an override this way (it just prints the label in my form, not the radio buttosn, if I don't do the override it does a standard checkbox)
My modelfield is defined as:
Class Mymodelname (models.Model):
fieldname = models.BooleanField(max_lengt...
Hi, I'm reaching back to my CLOS (Common Lisp Object System) days for this abstract question.
I'm augmenting the question to clarify:
It appears to me that a Python decorator is sort of like an "around" method in CLOS.
From what I remember, an "around" method in CLOS is a method/function that wraps around the primary method/functi...
I have the idea to use a regex pattern as a template and wonder if there is a convenient way to do so in Python (3 or newer).
import re
pattern = re.compile("/something/(?P<id>.*)")
pattern.populate(id=1) # that is what I'm looking for
should result in
/something/1
...
I have the wxPyhon following code
self.button1 = wx.Button(self, id=-1, label='Button1',pos=(8, 8), size=(175, 28))
self.button2 = wx.Button(self, id=-1, label='Button2',pos=(16, 8), size=(175, 28))
self.button1.Bind(wx.EVT_BUTTON, self.onButton)
self.button1.Bind(wx.EVT_BUTTON, self.onButton)
and I need to process the buttons on t...
I have this:
Lt = [('ABC', ), ('Abc', ), ('xyz', ),
('ABC', ), ('Abc', )]
I want this:
Lt = ('Abc', 'Abc', 'xyz', 'ABC', 'ABc')
remove the extra "(",")" and ",".... How do i do this.
...
I created a virtualenv environment with the --no-site-packages option. After activating the virtualenv, I noticed that importing psycopg2 at the "python" prompt would import the out of date system library I have but importing it at the "python2.6" prompt would import the newer version of the library I installed into the virtualenv.
Why...
I have a project set up as a notebook layout using wxpython. I am trying to create a help panel. The HtmlWindow object doesn't display the html page on the panel. No errors are displayed and a call to HtmlWindow.GetOpenedPage() returns the page name.
import wx
import wx.html as html
class HelpPanel(wx.Panel):
def __init__(self, ...
I have a function that is passed two values and then iterates over the range of those values. The values can be passed in any order, so I need to find which one is the lowest first. I had the function written like this:
def myFunc(x, y):
if x > y:
min_val, max_val = y, x
else:
min_val, max_val = x, y
for i i...
Given the following input file:
a = 2
b = 3
c = a * b
d = c + 4
I want to run the above input file through a python program that produces
the following output:
a = 2
b = 3
c = a * b = 6
d = c + 4 = 10
The input file is a legal python program, but the output is python with
extra output that prints the value of each variable to the r...
I'm trying to make embed Evince (libevview-2.30) in a Python and a C program, but it doesn't work. I'm using Ubuntu Lucid. Here is my C code:
#include <gtk/gtk.h>
#include <evince/2.30/evince-view.h>
#include <evince/2.30/evince-document.h>
int main(int argc, char *argv[]){
GtkWidget *window;
EvDocument *document;
EvDocumen...
I'm trying to have a select form with a list of months but I can't seem to get it to post correctly.
form:
class MonthForm(forms.Form):
months = [('January','January'),
('February','February'),
('March','March'),
('April','April'),
('May','May'),
...
It seem what i can do fast crawler with python in two ways:
thread pool with block sockets
non block sockets select,asyncore,etc..
i thnk where is no real need in thread here, and solution #2 better.
which is better and why?
...