python

Logout functionality in django

All In django project if 2 template windows are opened and if logout is triggered in 1 window the other window cookies are not cleared.How to delete the cookies also so that the logout will be triggered. def logout(request): //request = redirect('webbie.home.views.loginpage') //request.delete_cookie('user_location') return...

How to force Excel VBA to use updated COM server

I'm developing a COM server to be used from Excel VBA. When I update the server (edit code, unregister, re-register) Excel seems to carry on using the original version of the COM server, not the updated version. The only way I have found to get it to use the updated version is to close and re-open Excel, which gets a bit irritating. I...

Decrypt VIM encrypted file in Python

In my Python web app, I would need to decrypt a file that was encrypted using VIM. Assuming the web app knows the password used to encrypt the file in VIM, how do I write code to decrypt ? ...

Why isn't Python installed on Windows by default?

Or any other normal scripting language for that matter. I know there is VBScript and JScript. But I don't really like those for any kind of computing. I would really love to have python or ruby (or perl) interpreter installed with windows by default so when I write small console applications I wouldn't need to distribute whole python in...

Python 3.1.1 string to hex

I am trying to use str.encode() but I get >>> "hello".encode(hex) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: must be string, not builtin_function_or_method I have tried a bunch of variations and they seem to all work in Python 2.5.2, so what do I need to do to get them to work in Python 3.1? ...

User location information mapping with lastfm music track history in python

I have two separate python scripts. One is for getting user location information (which I get from web based geofeed provider.User Gsm is registerd with that services).Another is for retrieving lastfm user track history.I have already able to get user location data and user music track information. Goal is to map those two script in su...

Create new class object

Hi to all. I have 2 class in python cl1 in f1.py file and cl2 in f2.py file. I wrote import f2 import f2 class cl1: a = f2.cl2() But i see error in a = f2.cl2(): module object has no attribute 'cl2' Why? Thank you. ...

SVN pre-commit hook to reject Python files with inconsistent tab usage

The Python interpreter can be started with -tt to raise a TabError exception if the interpreted file has inconsistent tab usage. I'm trying to write a pre-commit hook for SVN that rejects files that raise this exception. I can pass the file being committed to python -tt but my problem is that the file is also executed, besides being che...

Django 1.1.1 chokes on multipart/form-data

Initial story I'm trying to implement file upload using a simple form (I'm pasting stripped version, but all important parts are included): <form method="POST" action="" enctype="multipart/form-data"> <input type="file" name="up_file" size="50"> <input type="hidden" name="cpk" value="{{c.pk}}"> <input type="submit" ...

calculate mean and variance with one iteration

Suppose I have an iterator of numbers, for example a file object: f = open("datafile.dat") now I want to do: mean = get_mean(f) sigma = get_sigma(f, mean) What is the best implementation? Suppose that the file is big ...

Pylons application Internationalization

What the best way to make pylons application internationalist? ...

how are pgp keys formatted?

i want to write a program in python to simply read pgp keys. however, i cant seem to find any documentation describing how pgp keys are formatted. i dont want to be searching through the source code of open pgp to look for source code that i wont be able to understand. say i open a public key, remove the top "-----BEGIN PGP PUBLIC KEY ...

how to make python to return floating point?

hi I want python to return 0.5 if I write 1/2 (and not 1.0/2.0). how do I make python to return the floating point? (I tried using getcontext().prec form decimal module) thanks Ariel ...

Python socket data returns <byte> object. How to regexp it?

I'm writing a basic html-proxy in python (3), and up to now I'm not using prebuild classes like http.server. I'm just starting a socket which accepts connection: self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.listen_socket.bind((socket.gethostname(), 4321)) self.listen_socket.listen(5) (a, b) = self.listen_...

remove default apps from django-admin

good day! by default, in django-admin, there is Users, Groups, ans Sites apps. How can i remove Groups and Sites? i was tried to remove admin.autodiscover() from root urls. Then, when i added smth like admin.site.register(User, UserAdmin) somewhere in my app models i got AlreadyRegistered exception (this is fairly right - models users ...

In a MVC patterned framework where would a screen-scraping module be located?

In a MVC patterned framework where would a screen-scraping module most logically be located? In the model or the controller? Or is it completely outside of this pattern? ...

Can I write parts of the Google App Engine code in Java, other parts in Python ?

Google App Engine supports both Python and Java application development. Can I have both in the same application? ...

wxPython Application.DoEvents() equivalent?

Is there an Application.DoEvents() equivalent in wxPython? I am creating a form, then doing a slow I/O event, and the form is only partially drawn until the event finishes. I'd like to have the form fully drawn before the I/O starts. I've tried self.Refresh(), but it has no effect. ...

Open a file in the proper encoding automatically

I'm dealing with some problems in a few files about the encoding. We receive files from other company and have to read them (the files are in csv format) Strangely, the files appear to be encoded in UTF-16. I am managing to do that, but I have to open them using the codecs module and specifying the encoding, this way. ENCODING = 'utf-1...

PyGreSQL NULLs for integer field

I am trying to insert some rows into a table which has a field of integers, which can be NULL: cur.execute("INSERT INTO mytable (id, priority) VALUES (%(id)d, %(priority)d)", \ {'id': id, 'priority': priority}) The priority variable is either an integer or None. This works when priority has an integer value, however, when ...