python

Set up svnperms pre-commit hook

I'm trying to implement svnperms into a repository, but am having difficulty with a few things: pre-commit has the execute permissions: -rwxrwxr-x 1 svnadm svn 3018 May 27 10:11 pre-commit This is my call to svnperms within pre-commit: # Check that the author of this commit has the rights to perform # the commit on t...

Is something like ConfigParser appropriate for saving state (key, value) between runs?

I want to save a set of key, value pairs (string, int) between runs of a Python program, reload them on subsequent runs and write the changes to be available on the next run. I don't think of this data as a configuration file, but it would fit the ConfigParser capabilities quite well. I would only need two [sections]. It's only a few hu...

Is there a list of Python packages that are not 64 bit compatible somewhere?

I am going to move to a 64 bit machine and a 64 bit OS (Windows) and am trying to figure out if any of the extensions/packages I am using are going to be lost when I make the move. I can't seem to find whether someone has built a list of known issues as flagged on the Python 2.5 release page. I have been using 2.5 but will at this tim...

How does Python OOP compare to PHP OOP?

I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable. If there are some issues in Python OOP wh...

Python equivalent of maplist?

What's the best Python equivalent of Common Lisp's maplist function? From the maplist documentation: maplist is like mapcar except that function is applied to successive sublists of the lists. function is first applied to the lists themselves, and then to the cdr of each list, and then to the cdr of the cdr of each list,...

WxPython differences between Windows and Linux

The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details. For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutorials don't work in my computer. So, do you know what important differ...

Sorting a tuple that contains lists

I have a similar question to this one but instead my tuple contains lists, as follows: mytuple = ( ["tomato", 3], ["say", 2], ["say", 5], ["I", 4], ["you", 1], ["tomato", 6], ) What's the most efficient way of sorting this? ...

Does Ruby have an equivalent of Python's twisted framework as a networking abstraction layer?

From my understanding, Python's twisted framework provides a higher-level abstraction for networking communications (?). I am looking for a Ruby equivalent of twisted to use in a Rails application. ...

how to write nslookup programmatically?

instead of using exec in our script to do an nslookup, is there an easy way to write it programmatically in PHP, Python, or Ruby? ...

Reinstall /Library/Python on OS X Leopard

I accidentally removed /Library/Python on OS X Leopard. How can I reinstall that? ...

When Should I Start Thinking About Moving to Python 3?

Possible Duplicate: Why won't you switch to Python 3.x? I see there are already a lot of duplicate questions asking whether or not new Python programmers should learn 2 or 3. I am not asking that question. I am already a Python 2 programmer. I started tinkering with it some years ago. I started using it almost exclusively for ...

How do I filter by time in a date time field?

In the model 'entered' is a datetime field. I want to query the data to find all entry's that where made between noon(start_time) and 5:00pm (end_time). selected = Entry.objects.filter(entered__gte=start_time, entered__lte=end_time) (as I expected)I get an error of: "ValidationError: Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.u...

Is there a way in Python to index a list of containers (tuples, lists, dictionaries) by an element of a container?

I have been poking around for a recipe / example to index a list of tuples without taking a modification of the decorate, sort, undecorate approach. For example: l=[(a,b,c),(x,c,b),(z,c,b),(z,c,d),(a,d,d),(x,d,c) . . .] The approach I have been using is to build a dictionary using defaultdict of the second element from collections...

How do I get to compare values of different datatypes (programmatic SSIS)

Hi, I am writing a data comparison code in python to compare the data transformed in the SSIS packages. So, I have all the modules written that accesses the each and every task in SSIS packages. It compares fairly well except for those data that have different datatype, same values but different decimal places. I started out converting...

Relative paths in Python

I'm building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don't, however, have the absolute path to the directory where the templates are stored. I do have a relative path from the script but when I call the script it treats that as a path relative to the current w...

Swig / Python memory leak detected

I have a very complicated class for which I'm attempting to make Python wrappers in SWIG. When I create an instance of the item in Python, however, I'm unable to initialize certain data members without receiving the message: >>> myVar = myModule.myDataType() swig/python detected a memory leak of type 'MyDataType *', no destructor found....

Python unicode in Mac os X terminal

Can someone explain to me this odd thing: When in python shell I type the following Cyrillic string: >>> print 'абвгд' абвгд but when I type: >>> print u'абвгд' Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-9: ordinal not in range(128)...

Are asynchronous Django model queries possible?

I'm new to Django, but the application that I have in mind might end up having URLs that look like this: http://mysite/compare/id_1/id_2 Where "id_1" and "id_2" are identifiers of two distinct Model objects. In the handler for "compare" I'd like to asynchronously, and in parallel, query and retrieve objects id_1 and id_2. Is there a...

My python program executes faster than my java version of the same program. What gives?

Update: 2009-05-29 Thanks for all the suggestions and advice. I used your suggestions to make my production code execute 2.5 times faster on average than my best result a couple of days ago. In the end I was able to make the java code the fastest. Lessons: My example code below shows the insertion of primitive ints but the producti...

Is there a better way than int( byte_buffer.encode('hex'), 16 )

In Python, I'm constantly using the following sequence to get an integer value from a byte buffer (in python this is a str). I'm getting the buffer from the struct.unpack() routine. When I unpack a 'char' using byte_buffer, = struct.unpack('c', raw_buffer) int_value = int( byte_buffer.encode('hex'), 16 ) Is there a better way? ...