My problem can be easily defined with the following code:
self.Bind(wx.EVT_MENU_OPEN, self.OnAbout)
This will mean that when I click on any wx.Menu() in the MenuBar, the function 'onAbout()' is called. How do I bind this event to a specific wx.Menu() which is called wx.MenuAbout() ?
If you are feeling extra helpful, perhaps you could...
I'm working in pylons with mako, and I'd like to create forms and validations with FormEncode for several parts of my application. I can't seem to find any good examples of the whole process. My question is twofold:
Technical
FancyValidators and Schemas - Their relationship and syntax
Pylons controllers and mako templates - how ...
In Python, I have a program snippet similar to the following that has the effect of running a custom command and returning the stdout data (or raise exception when exit code is non-zero):
proc = subprocess.Popen(
cmd,
# keep stderr separate; or merge it with stdout (default).
stderr=(subprocess.PIPE if ignore_stderr else sub...
How can you perform complex sorting on an object before passing it to the template? For example, here is my view:
@login_required
def overview(request):
physicians = PhysicianGroup.objects.get(pk=physician_group).physicians
for physician in physicians.all():
physician.service_patients.order_by('bed__room__unit', 'bed__room__orde...
Hi,
I'm trying to follow this tutorial from Cython: http://docs.cython.org/docs/tutorial.html#the-basics-of-cython and I'm having a problem.
The files are very simple. I have a helloworld.pyx:
print "Hello World"
and a setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import...
Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and/or a worked-...
I am using python language for google app engine based iphone application .I want to install/access ssl on python. I am unable to find a way to install/enable it in python file. please guide me how can I make my application to connect to ssl As I want to Apple enable push notification services on my application Its urgent.
...
I'm trying to do something relatively simple, spit out the column names and respective column values, and possibly filter out some columns so they aren't shown.
This is what I attempted ( after the initial connection of course ):
metadata = MetaData(engine)
users_table = Table('fusion_users', metadata, autoload=True)
s = users_table....
Hi there. Say I have the string "blöt träbåt" which has a few a and o with umlaut and ring above. I want it to become "blot trabat" as simply as possibly. I've done some digging and found the following method:
import unicodedata
unicode_string = unicodedata.normalize('NFKD', unicode(string))
This will give me the string in unicode for...
How to make tabulation look different than whitespace in vim (highlighted for example).
That would be useful for code in Python.
...
The following code ends with broken pipe when piped into tee, but behave correctly when not piped :
#!/usr/bin/python
import sys
def testfun():
while 1:
try :
s = sys.stdin.readline()
except(KeyboardInterrupt) :
print('Ctrl-C pressed')
sys.stdout.flush()
return
...
how determine the longest word?
First word, ok
'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)]
'a'
rfind is another subset
'a aa aaa aa'[:'a aa aaa aa'.rfind(' ',1,10)]
'a aa aaa'
One row should be able. It's a direct word 'a aa aaa...' and can be a
variable, no problem it occurs twice still naturally easier if
also occured just once....
I am using Python 2.6 and am getting [what I think is] unexpected output from re.sub()
>>> re.sub('[aeiou]', '-', 'the cat sat on the mat')
'th- c-t s-t -n th- m-t'
>>> re.sub('[aeiou]', '-', 'the cat sat on the mat', re.IGNORECASE)
'th- c-t sat on the mat'
If this output is what is expected, what is the logic behind it?
...
Hi,
I am searching for a good way to get relative paths of files and (sub)folders within a specific folder.
For my current approach I am using os.walk(). It is working but it does not seem "pythonic" to me:
myFolder = "myfolder"
fileSet = set() # yes, I need a set()
for root, dirs, files in os.walk(myFolder):
for fileName in fi...
I have a form like this:
class MyForm(forms.Form):
[...]
which is rendered in my view:
if request.method == 'GET':
form = MyForm(request.GET)
Now, i want to add a form field which contains a set of values in a select-field, and the queryset must be filtered by the currently logged in user. So I changed the method signature so t...
The code below is outdated in python 3.0 by being replaced by subprocess.getstatusoutput().
import commands
(ret, out) = commands.getstatusoutput('some command')
print ret
print out
The real question is what's the multiplatform alternative to this command from Python because the above code does fail ugly under Windows because getstat...
Is there a standard pythonic way to treat physical units / quantities in python? I saw different module-specific solutions from different fields like physics or neuroscience. But I would rather like to use a standard method than "island"-solutions as others should be able to easily read my code.
...
Is there a way to dynamically create unittest test cases? I have tried the following..
class test_filenames(unittest.TestCase):
def setUp(self):
for category, testcases in files.items():
for testindex, curtest in enumerate(testcases):
def thetest():
parser = FileParser(curtest...
Hi all
I have some code that uses pip to bootstrap a Python envionment for out build process: this is a lovely way of ensuring we get proper isolation of the build requirements from the rest of the host system, and helping us get more consistent build results overall.
Anyway, the code I have that drives pip.py appears to have some prob...
I'm having some memory issues while using a python script to issue a large solr query. I'm using the solrpy library to interface with the solr server. The query returns approximately 80,000 records. Immediately after issuing the query the python memory footprint as viewed through top balloons to ~190MB.
PID USER PR NI VIRT R...