python

Modify excel file in python on linux enviroment

hi, how do i insert few row in an existing excel file using python? the excel file maybe be of any excel version. On windows that could have been possible by using win32com.client...but i need to make the changes in the linux environment. how can i do it? ...

Noob: How to decode JSON with Python

I'm getting my JSON from reddit.com, essentially something like this. I have done quite a bit of reading, but I don't really understand how I can grab the information I want from this JSON (I want a list of the story links). I understand that I can "decode" the JSON into a dictionary, but do I need to recur throughout the JSON to get wha...

Emacs: Set/Reset python debug breakpoint

I use python debugger pdb. I use emacs for python programming. I use python-mode.el. My idea is to make emacs intuitive. So I need the following help for python programs (.py) Whenever I press 'F9' key, the emacs should put "import pdb; pdb.set_trace();" statements in the current line and move the current line to one line below. Senten...

Better way to represent Many to many relationship in django admin

I have a unique problem the way it should be handled in django admin. I have following models structure... class Product(models.Model): name = models.CharField(max_length = 100) base_price = models.DecimalField(max_digits = 5, decimal_places = 2) def __unicode__(self): return self.name class Country(models.Mo...

PyFacebook: Facebook() instance has no stream methods

I need to update my Facebook Fan Page in a django app so I have this code: import facebook from django.conf import settings def login_facebook(): fb = facebook.Facebook(settings.FACEBOOK_API_KEY, settings.FACEBOOK_SECRET_KEY) fb.session_key = settings.FACEBOOK_SESSION fb.secret = settings.FACEBOOK_SECRET_KEY fb.uid = se...

Migrate a SQLite3 database table to MySQL with Python without dump files

I need to migrate information that I created in SQLite3 to a MySQL database on my website. The website is on a hosted server. I have remote access to the MySQL database. I initially thought it would be easy, but I am not finding any good info on it, and everything I read seems to imply that you need to dump the SQLite3 file, convert i...

How do I read text from the (Mac OS X) clipboard from python?

Possible Duplicate: Can python send text to the Mac clipboard How can I read text from the clipboard from Python in Mac OS x? ...

customize the django admin panel ?

I want to change the django bydefault admin panel title bar where wirte the django administration. Actually I want to replace the django administration with the my site name. ...

How do I get my python object back from a QVariant in PyQt4?

I am creating a subclass of QAbstractItemModel to be displayed in an QTreeView. My index() and parent() function creates the QModelIndex using the QAbstractItemModel inherited function createIndex and providing it the row, column, and data needed. Here, for testing purposes, data is a Python string. class TestModel(QAbstractItemModel):...

Return common element indices between two numpy arrays

Hi all, I have two arrays, a1 and a2. Assume len(a2) >> len(a1), and that a1 is a subset of a2. I would like a quick way to return the a2 indices of all elements in a1. The time-intensive way to do this is obviously: from operator import indexOf indices = [] for i in a1: indices.append(indexOf(a2,i)) This of course takes a long...

Can't modify value returned by time.time() in Python code embedded in C++

Hi, I'm facing a very strange problem. The following code: import time target_time = time.time() + 30.0 doesn't work in Python code called from C++ (embedding)! target_time has the same value as time.time() and any attempt to modify it leaves the value unchanged in a pdb console... It happens after I've called root.initialise() ...

Python equivalents of the common Perl modules?

I need to rewrite some Perl code in python. So I'm looking for the closest modules to what I'm using now in Perl (i.e. with similar functionality and stability): DBI + DBD::mysql LWP::UserAgent WWW::Mechanize XML::LibXML HTML::TreeBuilder CGI::FormBuilder Template::Toolkit What are the Python equivalents to these? ...

atomic writing to file with Python

I am using Python to write chunks of text to files in a single operation: open(file, 'w').write(text) If the script is interrupted so a file write does not complete I want to have no file rather than a partially complete file. Can this be done? ...

Professional Exams for Python?

I am interested in python, does python have any professional certification exams like the one java has, such as scjp? or how can i obtain the professional certification for python? ...

A decent SSL library for Python 2.5

I am tasked with migrating a server's networking from plain sockets to SSL in python 2.5, and I've run into a snag. It seems that just about no SSL library out there fully implements the socket interface, so the code we currently have can't be straight migrated. Specifically, I can't seem to find a library that supports the 'setblocking...

Customizing the language-guessing algorithm in Django

I'm developing a multilingual Django website. It has two languages, English and Hebrew. I want the default language for every first-time visitor to be Hebrew, regardless of what his browser's Accept-Language is. Of course, if he changes language to English (and thus gets the language cookie or the key in the session), it should remain a...

How to parse a single line csv string without the csv.reader iterator in python?

I have a CSV file that i need to rearrange and renecode. I'd like to run line = line.decode('windows-1250').encode('utf-8') on each line before it's parsed and split by the CSV reader. Or I'd like iterate over lines myself run the re-encoding and use just single line parsing form CSV library but with the same reader instance. Is ther...

Error loading dll in path with parenthesis using ctypes (python)

Hello all! I am trying to access a dll located in the "c:/Program Files (x86)" folder in a 64-bits processor PC. If I use os.path.exists to check if the dll exists, I receive an afirmative answer: >>> print os.path.exists('c:/Program Files (x86)/Some Folder/SomeDll.dll') True But when I try to load the dll using ctypes, I get the fo...

Implementation hexagonal map (Self-Organizing Map) on Python

I am looking for hexagonal self-organizing map on Python. ready module. If one exists. way to plot hexagonal cell algorithms to work with hexagonal cells as array or smth else About: A self-organizing map (SOM) or self-organizing feature map (SOFM) is a type of artificial neural network that is trained using unsupervised learning t...

Django queries: how to make contains OR not_contains queries

Hello. I have to make a query that will get records containing "wd2" substring or not containing "wd" string at all. Is there any way to do it nicely? Seems something like: Record.objects.filter( Q(parameter__icontains="wd2") | Q( ## what should be here? ## ) ) ...