I use python tarfile module.
I have a system backup in tar.gz file.
I need to get first level dirs and files list without getting ALL the list of files in the archive because it's TOO LONG.
For example: I need to get ['bin/', 'etc/', ... 'var/'] and that's all.
How can I do it? May be not even with a tar-file? Then how?
...
Hello, I'm writing a CLI app and there is a place, where user should to write path to using dir. Of couse, I can read it with raw_input(), but standart Completer can't autocomplete path by TAB. So is there any solution in python (or somewhere else) or should I to write my own Completer?
...
Hi,
I'm trying to understand why I can't specify choices to a form field's widget if I'm overriding a ModelForm's field in Django. It works if I give the choices to the field but not the widget. My understanding is/was that if you give choices to a field it'll be passed onto the widget for rendering. I know I can get this to work with a...
I'm back with another longish question. Having experimented with a number of Python-based Damerau-Levenshtein
edit distance implementations, I finally found the one listed below as editdistance_reference(). It
seems to deliver correct results and appears to have an efficient implementation.
So I set down to convert the code to Cython. o...
I'm trying to set up Python's CGIHTTPServer on Mac OS X to be able to serve CGI scripts locally, but I seem to be unable to do this.
I've got a simple test script:
#!/usr/bin/env python
import cgi
cgi.test()
It has permissions -rwxr-xr-x@ and is located in ~/WWW (with permissions drwxr-xr-x). It runs just fine from the shell and I ...
I have a socket that I want to timeout when connecting so that I can cancel the whole operation if it can't connect yet it also want to use the makefile for the socket which requires no timeout.
Is there an easy way to do this or is this going to be a difficult thing to do?
Does python allow a reset of the timeout after connected so t...
I've noticed a lot about jobs being posted that require the applicant to know several languages or technologies. Especially I find this with web development. I don't really like this considering the point that the more you specialize in several things the less you actually know about each one. I recognize that this is good for the bottom...
I'm having trouble getting suds to consume complex (.net) webservice.
a. The generated suds soap message looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.cordys.com/Ucf/Organization/GlobalDomain/1.0" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://schemas.cordy...
Hi
I have a Pizza model and a Topping model, with a many-to-many relationship between the two.
Can you recommend an elegant way to extract:
the popularity (frequency) of each
topping
the correlation between
toppings (i.e. which sets of
toppings are most frequent)
Thanks
...
Hello, I need to compute the sizes of some python objects so I can break them up and store them in memcache without hitting size limits.
'sizeof()' doesn't seem to be present on python objects in the GAE environment and sys.getsizeof() is also unavailable.
GAE itself is clearly checking sizes behind the scenes to enforce the limits. A...
So I have a website already set up, and I need a comet server for a chat application. The site is built with twisted.web, and I want to build the comet server with twisted as well since I'm already somewhat familiar with it.
But I'm not sure how to do it. I've looked at this post and understand the mechanics in the code snippet -- but I...
I've been thinking about this far too long and haven't gotten any idea, maybe some of you can help.
I have a folder of python scripts, all of which have the same surrounding body (literally, I generated it from a shell script), but have one chunk that's different than all of them. In other words:
Top piece of code (always the same)
Mi...
I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb".
This is a fresh install right off python.org, so I assumed that it would have the MySQLDb module included, but it does not seem to. I also can't seem to find the module or how...
I am running iOS 4 on a jailbroken iPhone 3GS. Before I upgraded to iOS 4, I had installed Python on the iPhone and had found the following snippet of Python code to copy a variable (key in this case) to the pasteboard. I then was able to open another application and paste the value into a text field.
out = os.popen('\usr\bin\pbcopy',...
I want to get a running total from a list of numbers.
For demo purposes, I start with a sequential list of numbers using range
a = range(20)
runningTotal = []
for n in range(len(a)):
new = runningTotal[n-1] + a[n] if n > 0 else a[n]
runningTotal.append(new)
# This one is a syntax error
# runningTotal = [a[n] for n in range(le...
I'm not sure how to word this exactly but I have a script that downloads an SSL certificate from a web server to check it's expiration date.
To do this, I need to download the CA certificates. Currently I write them to a temporary file in the /tmp directory and read it back later but I am sure there must be a way to do this without writ...
How do I add a TODO comment in NetBeans 6.9 Python?
I have taken a look under Tools > Options > Miscellaneous > Tasks
However, when I add a comment to my source code:
# TODO This won't appear in the Tasks panel
TODO actually turns a different color, but the comment doesn't show up in my Tasks panel. Is there a way to fix this?
...
I get:
TemplateSyntaxError at /blog/post/test
Caught NameError while rendering:
global name 'forms' is not defined
for this code:
forms.py
from dojango.forms import widgets
from django.contrib.comments.forms import CommentForm
from Website.Comments.models import PageComment
class PageCommentForm(CommentForm):
title = widg...
The _ssl.sslwrap function appears to check to see if the sock passed in is a subclass of _socket.socket. I am passing in a class that implements the interface of _socket.socket.
It gets mad because my socket isn't a subclass. Is this something I should fix on my side, or is this something that I should ask about from the python-dev gu...
I want to add a column to a database table but I don't want to modify the 3rd party module in case I need/decide to upgrade the module in the future. Is there a way I can add this field within my code so that with new builds I don't have to add the field manually?
...