python

Books/web sites recommendation for learning Python

This is in continuance to the http://stackoverflow.com/questions/139017/learning-a-programming-language-at-an-elderly-age">previous question which I asked yesterday. I received an overwhelming response where community members encouraged me to have a go at a programming language. There were recommendations for learning languages such as P...

OCSP libraries for python / java / c?

Hi all! Going back to my previous question on OCSP, does anybody know of "reliable" OCSP libraries for Python, Java and C? I need "client" OCSP functionality, as I'll be checking the status of Certs against an OCSP responder, so responder functionality is not that important. Thanks ...

Which scripting language should I learn after Perl?

Hi, I have used Perl for many years now, mostly for doing all kinds of file parsing and system scripting jobs. Several newer scripting languages (python, ruby) are now available, that all in part tend to address scripting etc. in a better way than Perl apparently did. If I would have to choose learning a new scripting language, which ...

Crypto/x509 certificate parsing libraries for Python (pyOpenSSL vs Python OpenSSL Wrappers vs...)

Hi! Any recommended crypto libraries for Python. I know I've asked something similar in http://stackoverflow.com/questions/143523/, but I should've split the question in two. What I need is the ability to parse X.509 Certificates to extract the information contained in them. Looking around, I've found two options: Python OpenSSL Wra...

Is there any difference between "string" and 'string' in Python?

In PHP, a string enclosed in "double quotes" will be parsed for variables to replace whereas a string enclosed in 'single quotes' will not. In Python, does this also apply? ...

Has anyone found a good set of python plugins for vim -- specifically module completion?

I'm looking for a suite of plugins that can help me finally switch over to vim full-time. Right now I'm using Komodo with some good success, but their vim bindings have enough little errors that I'm tired of it. What I do love in Komodo, though, is the code completion. So, here's what I'm looking for (ordered by importance). Code com...

Significant figures in the decimal module

So I've decided to try to solve my physics homework by writing some python scripts to solve problems for me. One problem that I'm running into is that significant figures don't always seem to come out properly. For example this handles significant figures properly: from decimal import Decimal >>> Decimal('1.0') + Decimal('2.0') Decima...

Python PostgreSQL modules. Which is best?

I've seen a number of postgresql modules for python like pygresql, pypgsql, psyco. Most of them are Python DB API 2.0 compliant, some are not being actively developed anymore. Which module do you recommend? Why? ...

Python Vs. Ruby for Metaprogramming

I'm currently primarily a D programmer and am looking to add another language to my toolbox, preferably one that supports the metaprogramming hacks that just can't be done in a statically compiled language like D. I've read up on Lisp a little and I would love to find a language that allows some of the cool stuff that Lisp does, but wit...

Something like Explorer's icon grid view in a Python GUI

I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to implement it all myself. If ...

Calling C/C++ from python?

What would be the quickest way to construct a python binding to a C or C++ library? (using windows if this matters) ...

Text difference algorithm

Hi, I need an algorithm that can compare two text files and highlight their difference and ( even better!) can compute their difference in a meaningful way ( meaning, two similar files should have a similarity score higher than two dissimilar files, with the word "similar" defined in the normal terms). It sounds easy to implement, but i...

Python scope

Hello, I am trying to figure out this: c = 1 def f(n): print c + n def g(n): c = c + n f(1) => 2 g(1) => UnboundLocalError: local variable 'c' referenced before assignment Thanks! ...

How do I successfully pass a function reference to Django’s reverse() function?

I’ve got a brand new Django project. I’ve added one minimal view function to views.py, and one URL pattern to urls.py, passing the view by function reference instead of a string: # urls.py # ------- # coding=utf-8 from django.conf.urls.defaults import * from myapp import views urlpatterns = patterns('', url(r'^myview/$', views....

Do you use the "global" statement in Python ?

I was reading a question about the Python global statement ( "Python scope" ) and I was remembering about how often I used this statement when I was a Python beginner (I used global a lot) and how, nowadays, years later, I don't use it at all, ever. I even consider it a bit "un-pythonic". Do you use this statement in Python ? Has your u...

I'm using Python regexes in a criminally inefficient manner

My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this: This input: <%"TITLE"="This Is A Test Variable"%>The Web <%"TITLE"%> Should produce this output: The Web This Is A Test Variable I've got it working. But looking at my code, I'm running multi...

What's the simplest to way to retrieve a file over HTTP using Python?

What's the most efficient way of fetching a file from a URL using Python? ...

In Django, where is the best place to put short snippets of HTML-formatted data?

Hi there, This question is related to (but perhaps not quite the same as): http://stackoverflow.com/questions/61451/does-django-have-html-helpers My problem is this: In Django, I am constantly reproducing the basic formatting for low-level database objects. Here's an example: I have two classes, Person and Address. There are multiple...

Difflib.SequenceMatcher isjunk optional parameter query: how to ignore whitespaces, tabs, empty lines?

I am trying to use Difflib.SequenceMatcher to compute the similarities between two files. These two files are almost identical except that one contains some extra whitespaces, empty lines and other doesn't. I am trying to use s=difflib.SequenceMatcher(isjunk,text1,text2) ratio =s.ratio() for this purpose. So, the question is how to w...

How does one do the equivalent of "import * from module" with Python's __import__ function?

Given a string with a module name, how do you import everything in the module as if you had called: from module import * i.e. given string S="module", how does one get the equivalent of the following: __import__(S, fromlist="*") This doesn't seem to perform as expected (as it doesn't import anything). Thanks! ...