Im a trying to find a sublist of a list. Meaning if list1 say [1,5] is in list2 say [1,4,3,5,6] than it should return True. What I have so far is this:
for nums in l1:
if nums in l2:
return True
else:
return False
This would be true but I'm trying to return True only if list1 is in list2 in the respective order...
I use the following python function to mark an item as read in google reader, but it always returns error HTTPErrors: HTTP 401: Unauthorized:
def mark_as_read(SID, entryid):
token = get_token(SID)
mark_as_read_url = 'http://www.google.com/reader/api/0/edit-tag'
header = {'Content-type': 'application/x-www-form-urlencod...
I love to eat chicken.
Today I went running, swimming and played basketball.
My objective is to return FOOD and SPORTS just by analyzing these two sentences. How can you do that?
I am familiar with NLP and Wordnet. But is there something more high-level/practical/modern technology??
Is there anything that automatically categorizes w...
For example...
Chicken is an animal.
Burrito is a food.
WordNet allows you to do "is-a"...the hiearchy feature.
However, how do I know when to stop travelling up the tree? I want a LEVEL.
That is consistent.
For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn'...
How to create 3 dimensions matrix in numpy , like matlab a(:,:,:) . I try to convert matlab code that create 3d matrix to python by use numpy.array and i don't know how to create 3d matrix/array in numpy
...
Hi, imagine you have an io heavy function like this:
def getMd5Sum(path):
with open(path) as f:
return md5(f.read()).hexdigest()
Do you think Python is flexible enough to allow code like this (notice the $):
def someGuiCallback(filebutton):
...
path = filebutton.getPath()
md5sum = $getMd5Sum()
showNotifica...
Hi, I exported a .bin file from RealFlow 4 and now need to be able to read it in Python, to make an importer. How do these files work?
...
In our code we catch IOError and log it before reraising. I am getting a "connection reset by peer", but nothing in the logs. Is "connection reset by peer" a subclass of IOError in python?
.....
File "/usr/lib/python2.5/httplib.py", line 1047, in readline
s = self._read()
File "/usr/lib/python2.5/httplib.py", line 1003, in ...
The question is related to the answer about renaming files recursively.
The code, changed to replace dashes, does not work with cases such as:
./Beginners Tools/Hello's -Trojans-/bif43243
./Linux/Nux Col - 1 Works (TEX & Pdf) - T'eouhsoe & More (33323 - 34432)
./Git/peepcode-git-mov/c6_branch_merge.mov
./haskell/OS 2007 - T aoue
./B Si...
I am not sure what is return value of subprocess.call() (with shell=True).
Can I safely assume a zero value will always mean command executed successfully.
Is return vale == exit staus of a shell command ??
Will following piece of code work for virtually any command on linux?
e.g.
cmd = "foo.txt > bar.txt"
ret = subprocess.call(cmd...
I wrote an audio broadcasting server with Python/Twisted. It works fine, but the usage of memory grows too fast! I think that's because some user's network might not be good enough to download the audio in time.
My audio server broadcast audio data to different listener's client, if some of them can't download the audio in time, that m...
I'm working on a not-so-big project in django that will among other things incorporate a forum system.
I have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts.
The thing is I can't really think of a way to properly store that informatio...
I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...})
As this is a client-side app, I don't want to use a database server, I just want the info stored into files.
I want the files to be readable from various languages (at least pyt...
A random class definition:
class ABC:
x = 6
Setting some values, first for the abc instance, later for the static variable:
abc = ABC()
abc.x = 2
ABC.x = 5
and then print the results:
print abc.x
print ABC.x
which prints
2
5
Now, I don't really get what is going on, because if i replace in the class definition x = 6 for "...
I want to write a code in python to solve a sudoku puzzle. Do you guys have any idea about a good algorithm for this purpose. I read somewhere in net about a algorithm which solves it by filling the whole box with all possible numbers, then inserts known values into the corresponding boxes.From the row and coloumn of known values the kno...
I want
Stats.singleton.twitter_count += 1
and I thought I could do
class Stats:
singleton_object = None
@property
@staticmethod
def singleton():
if Stats.singleton_object:
return Stats.singleton_object
Stats.singleton_object = Stats()
return Stats.singleton()
But it throws an exc...
Is there a recommended way of using Django to clean an input string without going through the Django form system?
That is, I'm writing code that delivers form input via AJAX so I'm skipping the whole Form model django offers. But I do want to clean the input prior to submission to the database.
...
I have two arrays (a and b) with n integer elements in the range (0,N).
typo: arrays with 2^n integers where the largest integer takes the value N = 3^n
I want to calculate the sum of every combination of elements in a and b (sum_ij_ = a_i_ + b_j_ for all i,j). Then take modulus N (sum_ij_ = sum_ij_ % N), and finally calculate the fre...
Sorry if this is a very stupid question. I am trying to use threads in a Python project I am working on, but threads don't appear to be behaving as they are supposed to in my code. It seems that all threads run sequentially (i.e. thread2 starts after thread 1 ends, they don't both start at the same time). I wrote a simple script to test ...
I want to move a document into a folder. The client API for that is MoveIntoFolder
gd_client.MoveIntoFolder(self, source_entry, folder_entry)
#folder_entry: DocumentListEntry An object with a link
#to the destination folder
I can't figure out how to get folder_entry from the client API. Digging into the protocol I think I ...