I have an assignment said that to create a findString function that accept 2 string which are 'target' and 'query', and that returns
a
list
of
all
indices
in
target
where
query
appears.
If
target
does
not
contain
query,
return
an
empty
list.
For example:
findString(‘attaggtttattgg’,’gg’)
return:
[4,12]
I dont kno...
My assignment ask to make a function call readFasta that
accepts
one
argument:
the
name
of
a
fasta
format
file
(fn)
containing
one
or
more
sequences.
The
function
should
read
the
file
and
return
a
dictionary
where
the
keys
are
the
fasta
headers
and
the
values
are
the
corresponding
sequences
from
f...
I want to use sphinx's autodoc-skip-member event to select a portion of the members on a certain python class for documentation.
But it isn't clear from the sphinx docs, and I can't find any examples that illustrate: where do I put the code to connect this? I see Sphinx.connect and I suspect it goes in my conf.py, but when I try variati...
Ok say I have a string in python:
str="martin added 1 new photo to the <a href=''>martins photos</a> album."
the string contains a lot more css/html in real world use
What is the fastest way to change the 1 ('1 new photo') to say '2 new photos'. of course later the '1' may say '12'.
Note, I don't know what the number is, so doing a r...
What do I put in passenger_wsgi.py for a Turbogears2 site?
Since it's possible for Django to use mod_passenger, I'm trying to use mod_passenger with Turbogears2. So far, I've found a passenger_wsgi.py for Turbogears1, but I don't know where to start to make a passenger_wsgi.py for a Turbogears2 site.
Here's the Turbogears1 example: ht...
I'm trying to change the behaviour of a Django model to allow me to access a foreign key's properties directly from the parent, e.g.
cache.part_number
vs
cache.product.part_number
I've tried overriding the __getattr__ method as follows, but I get a recursion error when I try to access the foreign key's properties
class Product(mo...
Hello,
I'm currently developing a torrent metainfo management library for Ruby.
I'm having trouble reading the pieces from the files. I just don't understand how I'm supposed to go about it. I know I'm supposed to SHA1 digest piece length bytes of a file once (or read piece length bytes multiple times, or what?)
I'm counting on your h...
In Ruby you can read from a file using s = File.read(filename). The shortest and clearest I know in Python is
with file(filename) as f:
s = f.read()
Is there any other way to do it that makes it even shorter (preferably one line) and more readable?
Note: initially I phrased the question as "doing this in a single line of code". A...
Hello everyone,
I'm trying to access Apples iCal-Server on a Mac OS X Snow Leopard Server via Python. The server is up and running and working with it via the iCal-Application is just fine.
Now I need to access this server via Python to use it as backend for resource planning. I have already looked at the CalDav-Module (http://packages....
Hello everyone,
Is there any production ready open source twitter clones written in Ruby or Python ?
I am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc)
Thanks !
...
I have wxpython application that run over a list of files on some directory and proccess the files line by line
I need to build a progress bar that show the status how records already done with wx.gauge control
I need to count the number of the records before i use the wx.guage in order to build the progress bar ,
is this the way to do ...
I am new to django and have gotten a bit stuck on trying to make the admin site work as I'd like it to. I am wondering if for making the admin functionality I want it is better to make a custom admin app with a template inheriting from admin/base_site.html, using the frontend login with a redirect when is_staff is true.
The initial d...
I've been looking for how to do this and I've found places where the subject comes up, but none of the suggestions actually work for me, even though they seem to work out okay for the questioner (they don't even list what to import). I ran across self.setWindowFlags(Qt.FramelessWindowHint) but it doesn't seem to work regardless of the im...
I'm looking to use Google AppEngine (Python). The Tipfy framework looks very good. How do I add PayPal and/or Google Web Payments into my app.
Is there a simple extension or similar that I can drop in?
...
I have a file structure like this:
data
mydata.xls
scripts
myscript.py
From within myscript.py, how can I get the filepath of mydata.xls?
I need to pass it to xlrd:
book = xlrd.open_workbook(filename)
and relative filepaths like '../data/mydata.xls' don't seem to work.
...
Hi all,
I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is...
I'm building a facebook app, and my users table's keyName is set to the Uid of the facebook user. I found this to be efficient because I can use db.Key.from_path() to efficiently query the datastore for a particular user instead of doing a query (where uid = x, limit = 1). This is actually my first time using key names.
But when I did ...
I have a string that looks and behaves as follows (Python code provided). WTF?! What encoding is it in?
s = u'\x00Q\x00u\x00i\x00c\x00k'
>>> print s
Quick
>>>
>>> s == 'Quick'
False
>>>
>>> import re
>>> re.search('Quick', s)
>>>
>>> import chardet
>>> chardet.detect(s)
/usr/lib/pymodules/python2.6/chardet/universaldetector.py:69: Unico...
Hi, I need to avoid creating double branches in an xml tree when parsing a text file. Let's say the textfile is as follows (the order of lines is random):
branch1:branch11:message11
branch1:branch12:message12
branch2:branch21:message21
branch2:branch22:message22
So the resulting xml tree should have a root with two branches. Both of th...
Django when i send the following string from an ajax submit i get the following string in unicode.How to decode this
$.post("/records/save_t/",snddata,
function(data){
if(data == 0 ){
}
},"json");
In django
def save_t(request):
if request.method == 'GET':
qd = request.GET
elif request.method =...