python

error when exec'ing scp from python

hi, this code is giving following error: os.system("scp %s:/export/home/sample/backup.sql %s:/home/rushi/abc.sql" % (a, b)) Permission denied (publickey,keyboard-interactive). lost connection a and b are the command line arguments which accept user name and machine name as arguments: eg: [email protected] . ...

How to pickle and unpickle instances of a class that inherits from defaultdict?

I have a class that inherits from defaultdict like this: class listdict(defaultdict): def __init__(self): defaultdict.__init__(self, list) I can pickle it, but when I unpickle it, this happens: ('__init__() takes exactly 1 argument (2 given)', <class 'listdict'>, (<type 'list'>,)) The class does not define any special m...

Fastest way to sort in Python

What is the fastest way to sort an array of whole integers bigger than 0 and less than 100000 in Python? But not using the built in functions like sort. Im looking at the possibility to combine 2 sport functions depending on input size. ...

Is unladen-swallow dead?

My project has deferred solution on integration C++ with Python until now. But now this question is raised again. Do anybody know status of project? On Google: (http://code.google.com/p/unladen-swallow) there is no actual info at all. Can we reckon on this project? ...

how to upload a file with the friendfeed-api python library?

Anyone knows this library? I'd like to know how if (and how) I can use it to send one or more images on my friendfeed account - the documentation basically says nothing. thank you. ...

vimrc error and config python on windows xp

I am using XP SP3 and have installed vim 7.3. I was following a how-to I found here in a previous thread on configuring vim for a python editor. http://www.sontek.net/post/Python-with-a-modular-IDE-%28Vim%29.aspx I am getting an error when starting gvim that it cannot find python27.dll. This is correct I don't have python 2.7 installed...

How do I run a local server in Python??

is there any module? what are their instructions? ...

Need Help Extracting embedded ole from office files programmatically under Linux (python or c or any program that is console).

Hello SO i am having trouble trying to extract embedded documents inside Office <2003 . I am able to parse and index office files but i need to index embedded ole documents also. How can i achieve? Any lib for python or command line programs? i found ripole: www.pldaniels.com/ripole/ , but it just giving me Segfault.. I need native p...

Get recall (sensitivity) and precision (PPV) values of a multi-class problem in PyML

I am using PyML for SVM classification. However, I noticed that when I evaluate a multi-class classifier using LOO, the results object does not report the sensitivity and PPV values. Instead they are 0.0: from PyML import * from PyML.classifiers import multi mc = multi.OneAgainstRest(SVM()) data = VectorDataSet('iris.data', labelsColum...

Longest distinct consecutive list in Python

I have a list: a = [2, 3, 5, 6, 6, 7, 10, 11, 13, 14, 15, 16, 16, 17, 18, 20, 21] Is it possible to make a function that shows the longest list of distinct, consecutive elements? Please, show how to do it In this case the answer should be: 13, 14, 15, 16, 17, 18 ...

How to write tag deleter script in python

I want to implement a file reader (folders and subfolders) script which detects some tags and delete those tags from the files. The files are .cpp, .h .txt and .xml And they are hundreds of files under same folder. I have no idea about python, but people told me that I can do it easily. EXAMPLE: My main folder is A: C:\A Inside A, I...

UnicodeEncodeError when reading pdf with pyPdf

Guys i had posted a question earlier http://stackoverflow.com/questions/3854963/pypdf-python-tool .dont mark this as duplicate as i get this error indicated below import sys import pyPdf def convertPdf2String(path): content = "" # load PDF file pdf = pyPdf.PdfFileReader(file(path, "rb")) # iterate pages ...

Python Code Completion

After using C# for long time I finally decided to switch to Python. The question I am facing for the moment has to do about auto-complete. I guess I am spoiled by C# and especially from resharper and I was expecting something similar to exist for Python. My editor of choice is emacs and after doing some research I found autocomplete.pl,...

right-to-left languages in Python

Hi, I want to write a Hebrew string in Python and then show it onscreen. The problem is that I get a mirror view of what I wrote. How can I set the string to use RTL instead of left to right? ...

Call Class Method from another Class

So in Python, I am wondering if there is a way to call a class method from another class? I am attempting to spin my own MVC framework in Python and I can not for the life of me figure out how to invoke a method from one class in another class. Below is basically what I want to happen: class A: def method1(arg1, arg2): # do...

Installing the igraph package for python

Dear Pythonistas, I have downloaded the igraph 0.5.4 tar ball for macosx Leopard 10.5.8. When I unpack it and then run: sudo python setup.py install I get the following long error message: Include path: /usr/include /usr/local/include Library path: running install running bdist_egg running egg_info writing python_igraph.egg-inf...

URL Redirect with Python / Django / Mod-Rewrite

I am trying to setup a URL redirect for a Q&A site I am setting up for Boat Repairs. I want boatrepaired.com to go to www.boatrepaired.com. I am generally a php guy so I am a bit confused with python etc. used by OSQA. I added this to my apache conf file... <Directory /opt/OSQA/> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^...

django project directory structure and the python path

I am trying to get the best possible set up for developing my django project from the start and I'm having trouble getting everything to play nicely in the directory structure. I have set up virtualenv's (env in this example) so that I can deploy a clean empty python environment for every django project. The basic structure is as follow...

IronPython & WPF: Binding a checkbox's IsChecked property to a class member variable

I've seen many similar questions on how to get data binding working with a checkbox, but all of the examples I've seen are in C# and I can't seem to make the leap to convert it to IronPython. I have a checkbox defined in a window thusly: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://sc...

Lisp's apply and funcall vs Python's apply

Lisp's apply is for Lisp's APPLY is for calling functions with computed argument lists stored in lists.(Modified from Rainer's comment) For example, the following code changes (list 1 2 3) to (+ 1 2 3). (apply #'+ '(1 2 3)) However, Python's apply does what Lisp's funcall does, except for some minor differences (input is given as t...