Suppose I have this table:
ID | description
-------------------
5 | The bird flew over the tree.
2 | The birds, flew over the tree
These two rows have "similar" content. How would I remove #2?
What algorithm should I use for "similar" text?
How would I do this with Python?
Thanks!
...
I'm doing some Python coding in a clients code base and I stumbled on a line of code that looks something like this (the variable names have been changed to protect the innocent):
reply = function1(a=foo, **function2(bar, b=baz))
Normally ** in the argument list collects remaining keyword arguments but what do they do in front of the ...
How do I check if the database file already exists or not?
And, if the it exists, how do I check if it already has a specific table or not?
...
I have a wxPython ListCtrl with five columns. Four of these hold strings, the last one has integer values. I have been storing these as strings (i.e. '4', '17', etc.). However, now that I have added a ColumnSorterMixin to let me sort specific columns in the list, I'm finding, of course, that the integer column is being sorted lexically r...
I have a model like this:
class Task(models.model):
TASK_STATUS_CHOICES = (
(u"P", u'Pending'),
(u"A", u'Assigned'),
(u"C", u'Complete'),
(u"F", u'Failed')
)
status = models.CharField(max_length=2, choices=TASK_STATUS_CHOICES)
prerequisites = models.ManyToManyField('self', symmetrical=Fals...
#!/usr/bin/python
numbers = [1, 2, 3, 5, 6, 7]
clean = numbers.insert(3, 'four')
print clean
# desire results [1, 2, 3, 'four', 5, 6, 7]
I am getting "None". What am I doing wrong?
...
I'm developing a script which monitors a service for failure and launches another a different action depending on if failure is present or not.
I require a python script to monitor the output from a python program "monitor-services" and parsing the output search for an occurance of the word "failure". If present, the script should retu...
This is a very basic question - but I haven't been able to find an answer by searching online.
I am using python to control ArcGIS, and I have a simple python script, that calls some pre-written code.
However, when I make a change to the pre-written code, it does not appear to result in any change. I import this module, and have tried ...
How do I install SciPy on my system?
Update 1: for the NumPy part (that SciPy depends on) there is actually an installer for 64 bit Windows: numpy-1.3.0.win-amd64-py2.6.msi (is direct download URL, 2310144 bytes).
Running the SciPy superpack installer results in this
message in a dialog box:
"Cannot install. Python version 2.6 require...
I need a library to handle computational geometry in a project, especially boolean operations, but just about every feature is useful. The best library I can find for this is CGAL, but this is the sort of project I would hesitate to make without garbage collection.
What language/library pairs can you recommend? So far my best bet is i...
I use IPython very frequently and happily. Somehow, cutting text from the shell using the keyboard shortcut, Ctrl-X, is broken. Actually, I have a few different installations of IPython. In some of the installations, the shortcut works; in the others, it doesn't work.
What might be the reason for this? Where should I look into?
...
It seems that if I want to create a very basic Cocoa application with a dock icon and the like, I would have to use Xcode and the GUI builder (w/ PyObjC).
The application I am intending to write is largely concerned with algorithms and basic IO - and thus, not mostly related to Apple specific stuff.
Basically the application is suppose...
Hi!
What algorithm is the built in sort() method in python using? Is it possible to have a look at the code for that method?
Thanks =)
...
I'd like to use python scripts as plugins for an app I'm developing. This seems to be possible by interacting with android-scripting-environment (ASE), as is done by Locale, but I haven't found any documentation about this. How you execute ASE scripts from your own app?
...
I'm modifying Python code that have this form:
def foo(self):
try:
connect socket
except Exception, e:
some error reporting stuff
return an error
use the socket
do some other stuff
if some condition:
return
do some more stuff
socket.close()
return normally
Coming from ...
Hi there guys, I'm locked in using C# and I don't like it one bit. I have to start branching out to better myself as a professional and as a person, so I've decided to start making things in my own time using Python.
The problem is, I've basically programmed only in C#. What IDE should I use to make programs using Python?
My goal is to...
Hello everyone I'm currently new to python, and I'm trying to write a program where the user can input a message and the output will show the numeric code of the message, but at the same time I need to write the numeric code to an additional file.
So for example the user inputs the word "Hello"
The user will see the output "72 101 108 1...
I'm looking for a way to generate .deb and .rpm packages from my build scripts, containing the resulting products. Since everything is written in Python, I'm wondering if anyone knows of an abstraction layer that would allow me to drive both RPM and Deb construction from the same code?
...
I use the following code to stream large files from the Internet into a local file:
fp = open(file, 'wb')
req = urllib2.urlopen(url)
for line in req:
fp.write(line)
fp.close()
This works but it downloads quite slowly. Is there a faster way? (The files are large so I don't want to keep them in memory.)
...
I have a Django Model with a text field. I would like to modify the content of the text field before it's presented to the user in Django Admin.
I was expecting to see signal equivalent of post_load but it doesn't seem to exist.
To be more specific:
I have a text field that takes user input. In this text field there is a read more sep...