Hello everyone, I am trying to process various texts by regex and NLTK of python -which is at http://www.nltk.org/book-. I am trying to create a random text generator and I am having a hard time with a problem. First, here is my algorithm:
Enter a sentence as input -this is called trigger string-
Get longest word in trigger string
Sear...
Application consists of:
main process (python+sqlalchemy) that
periodically check db (sleeps most
of the time)
child processes that write to db
web app that write to db
Problem is that the main process session doesn't seem to register changes in the db done outside that session. How do ensure it does? (as of now I am closing and...
Hello all. I have a simple question. If I have a for loop in python as follows:
for name in nameList:
How do I know what the index is for the element name? I know I can some something like:
i = 0
for name in nameList:
i= i + 1
if name == "something":
nameList[i] = "something else"
I just feel there should be a more ...
I needed some help in model design. I wanted a model where a user can associate himself with numerous emails by submitting them from a form. And when the user wants to use the websites contact form, he can choose the email he wants a reply on. Will it be something like this :
class Email(models.Model):
author = models.ForeignKey(Us...
Im trying to import a couple of thousand issues from Roundup to Trac.
The usual Ticket Importer plug-in in Trac requires a csv in Trac format. Are there any solutions that can convert from roundup, or will I need to write my own?
...
I tagged this question with poisson as I am not sure if it will be helpful in this case.
I need to create a distribution (probably formatted as an image in the end) from a list of data.
For example:
data = [1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 10, 10, 10, 22, 30, 30, 35, 46, 58, 59, 59]
such that the data can be used to create a visu...
I have a tree based dataset that I want to visualize in my webpage. the data is just your basic tree: there is a parent node, with subnodes and then subnodes of those nodes.
I am looking for a package to visualize the data in a tree format. does anyone know of one? Google has one, but Im wondering if there ar other alternatives
...
How to replace a set of characters inside another string in Python?
Here is what I'm trying to do: let's say I have a string 'abcdefghijkl' and want to replace the 2-d from the end symbol (k) with A. I'm getting an error:
>>> aa = 'abcdefghijkl'
>>> print aa[-2]
k
>>> aa[-2]='A'
Traceback (most recent call last):
File "<pyshell#2>",...
Is there any way to check if two objects have the same values, other than to iterate through their attributes and manually compare their values?
Thanks in advance!
...
What would be a smart way to mix two strings in python?
I need something to insert one string into another one with specified (default=1) intervals:
>>> aa = 'abcdefghijkl'
>>> bb = mix(aa)
>>> bb
'a b c d e f g h i j k l '
>>> cc = mix(bb,'\n',8)
>>> print cc
a b c d
e f g h
i j k l
Is there an elegant way to write the 'mix' code...
I know I can use subprocess.Popen to run an executable, and potentially redirect stdin and stdout to files / using pipes to my process. Is there a way to run an executable such that the spawned process has no relation to the current Python process, however? Meaning, I want to start a process in the same way as if I would double-click on ...
Hi,
i have a huge list of two-element tuples which are coordinates of segments (start, end). In this way in a list below
list = [ (1,4), (2, 3), (10, 20), (18, 45) ]
there are 4 segments with their start and end localization. I would like to remove segments that overlap. I expect to have a list like this as a result:
list = [ (1,4...
I have a datetime object created like this:
tm = datetime.datetime.strptime('2010 Aug 04 14:15:16', '%Y %b %d %H:%M:%S')
>>> tm
datetime.datetime(2010, 8, 4, 14, 15, 16)
I then set the timezone like this:
tm.replace(tzinfo=pytz.timezone('UTC'))
>>> tm
datetime.datetime(2010, 8, 4, 14, 15, 16, tzinfo=<UTC>)
Eventually, I change the ...
I create a wx.TextEntryDialog as follows:
import wx
dlg = wx.TextEntryDialog(self, 'Rules:', 'Edit rules',
style=wx.TE_MULTILINE|wx.OK|wx.CANCEL)
dlg.SetValue(self.rules_text.Value)
if dlg.ShowModal() == wx.ID_OK:
…
This results in a dialog box that is too small for my needs, and that is not resizable:
...
Hi everyone,
i just can't seem to find a definitive answer to this issue, and django's irc needs auth to services...
So my question is : how can you force some kind of formatting for FloatFields in template when you're using Django ?
The problem is simple i need simple dot separated numbers like this : 42547.34
And i end up with comma ...
I would like to know if there is a library that will tell me approximately how similar two strings are
I am not looking for anything specific, but in this case:
a = 'alex is a buff dude'
b = 'a;exx is a buff dud'
we could say that b and a are approximately 90% similar.
Is there a library which can do this?
...
I have a python class and within the class I call 2 different methods from one of the other methods. One works and one gives me a TypeError: get_doms() takes exactly 1 argument (2 given) :
def start(self,cursor):
recs = self.get_recs(cursor) # No errors here
doms = self.get_doms(cursor) # I get a TypeError here
def g...
I currently have a python file with a bunch of global variables with values. I want to change these values permanently from a separate python script. I've tried setattr and such but it doesnt seem to work. Is there a way to do this?
...
I'm kind of confused by this because it seems that Django templates have optional HTML filters but this seems to be happening automatically.. I am making this demo app where the user will do an action that calls a python script which retrieves a url, I then want to display this in a new window.. its all fine except when the display comes...
I'm using PyQT4 to create a little GUI that allows people in my lab to write notes about physiological experiments. Right now I've got plain text editing going but it would be nice if the user could use rich text editing to set the currently selected text's font properties, bold/italic/font/font size would be sufficient. I am specificall...