python

Need help for developing facebook app

hi, I am trying to develop facebook app using django. The problem I am facing is how to use facebook api and get user friend list. view.py def canvas(request): # Get the User object user, created = FacebookUser.objects.get_or_create(id = request.facebook.uid) return direct_to_template(request, 'canvas.fbml', extra_context...

What i need to install python 2.5 on SCO 5.0.5

I would love to install python2.5 on sco unix, and am wondering anybody who has attempted to do this? ...

I need a sample of python unit testing sqlalchemy model with nose

Can someone show me how to write unit tests for sqlalchemy model I created using nose. I just need one simple example. Thanks. ...

Returning http status codes in Python CGI

Is it possible to send a status code other than 200 via a python cgi script (such as 301 redirect) ...

Django theme/skin repository

Is there some place of freely available themes/skins for standard Django apps? I mean the typical stuff containing footer, header, etc. ...

Threading TCP Server as proxy between connected user and unix socket.

I'm writing web application where I need to push data from server to the connected clients. This data can be send from any other script from web application. For example one user make some changes on the server and other users should be notified about that. So my idea is to use unix socket (path to socket based on user #ID) to send dat...

How to install python-igraph on Ubuntu 8.04 LTS 64-Bit?

Apparently libigraph and python-igraph are the only packages on earth that can't be installed via apt-get or easy_install under Ubuntu 8.04 LTS 64-bit. Installing both from source from source on seems to go smoothly...until I try to use them. When I run python I get: >>> import igraph Traceback (most recent call last): File "<stdin>...

Python ASCII Graph Drawing

Hi, I'm looking for a library to draw ASCII graphs (for use in a console) with Python. The graph is quite simple: it's only a flow chart for pipelines. I saw NetworkX and igraph, but didn't see a way to output to ascii. Do you have experience in this? Thanks a lot! Patrick EDIT 1: I actually found a library doing what I need, but i...

How to do fuzzy string search without a heavy database?

I have a mapping of catalog numbers to product names: 35 cozy comforter 35 warm blanket 67 pillow and need a search that would find misspelled, mixed names like "warm cmfrter". We have code using edit-distance (difflib), but it probably won't scale to the 18000 names. I achieved something similar with Lucene, but as PyLucene only...

Mapping a database table to an attribute of an object

I've come across a place in my current project where I have created several classes for storing a complicated data structure in memory and a completed SQL schema for storing the same data in a database. I've decided to use SQLAlchemy as an ORM layer as it seems the most flexible solution that I can tailor to my needs. My problem is tha...

Python's FTPLib too slow ?

I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten times as long in Python th...

authentication method

I am writing a server-client application to receive user message and publish it. Thinking about authentication method. Asymmetric encryption, probably RSA. Hash (salt+password+'msg'+'userid'), SHA256 HMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data. Symmetric Encryption of the '...

Has anyone used Sphinx to document a C++ project?

Sphinx is a new documentation tool for Python. It looks very nice. What I'm wondering is: How suitable this is for documenting a C++ project? Are there any tools for converting existing documentation (e.g. doxygen) to Sphinx format? Are there online/downloadable examples of C++ projects that use Sphinx? Any tips from anyone who has use...

Python dictionary: are keys() and values() always the same order?

It looks like the lists returned by keys() and values() methods of a dictionary are always a 1-to-1 mapping (assuming the dictionary is not altered between calling the 2 methods). For example: >>> d = {'one':1, 'two': 2, 'three': 3} >>> k, v = d.keys(), d.values() >>> for i in range(len(k)): print d[k[i]] == v[i] True True True ...

Extending Python's builtin Str

I'm trying to subclass str, but having some difficulties due to its immutability. class DerivedClass(str): def __new__(cls, string): ob = super(DerivedClass, cls).__new__(cls, string) return ob def upper(self): #overridden, new functionality. Return ob of type DerivedClass. Great. caps = super(D...

Can I use a List Comprehension to get Line Indexes from a file?

I need to identify some locations in a file where certain markers might be. I started off thinking that I would use list.index but I soon discovered that returns the first (and only the first) item. so I decided to implement my own solution which was count=0 docIndex=[] for line in open('myfile.txt','r'): if 'mystring' in line: ...

Elixir (SqlAlchemy): relations between 3 tables with composite primary keys

I've 3 tables: A Company table with (company_id) primary key A Page table with (company_id, url) primary key & a foreign key back to Company An Attr table with (company_id, attr_key) primary key & a foreign key back to Company. My question is how to construct the ManyToOne relation from Attr back to Page using the existing columns in...

How can I set a custom response header for pylons static (public) files?

How do I add a custom header to files pylons is serving from public? ...

How can I tell if a python variable is a string or a list?

I have a routine that takes a list of strings as a parameter, but I'd like to support passing in a single string and converting it to a list of one string. For example: def func( files ): for f in files: doSomethingWithFile( f ) func( ['file1','file2','file3'] ) func( 'file1' ) # should be treated like ['file1'] How can ...

How to programatically combine two aac files into one?

I'm looking for a cat for aac music files (the stuff iTunes uses). Use Case: My father in law will not touch computers except for audiobooks he downloads to his iPod. I have taught him some iTunes (Windows) basics, but his library is a mess. It turns out, that iTunes is optimized for listening to podcasts and random songs from your libr...