python

read file from server with some offset

How can I read file from server starting with some offset (Similar behavior to wget -c)? What headers I must send to server? What futures must server support? ...

how do i store the output of my cursor object to a text file?

I have accessed a database and have the result in a cursor object. when I try to save it to a text file, python says TypeError: argument 1 must be string or read-only character buffer, not sqlite3.Cursor can someone tell me what I should do here? curobject.execute('select * from device_auth') for row in curobject: print ...

How to create a read-only class property in Python?

Essentially I want to do something like this: class foo: x = 4 @property @classmethod def number(cls): return x Then I would like the following to work: >>> foo.number 4 Unfortunately, the above doesn't work. Instead of given me 4 it gives me <property object at 0x101786c58>. Is there any way to achieve ...

Is there a way to set the value of wsgi.input when testing?

When using wsgiref.util.setup_testing_defaults() to set up a WSGI environ is it possible to set the wsgi.input value so that one can test HTTP POST requests? Investigating the wsgi.input value created by setup_testing_defaults() shows that it's a wsgi.validate.InputWrapper object with read, readline, readlines, input, close, and __iter_...

How to make persistent a python dictionary on google appengine

Using datastore framework of appengine, what's the pythonic way to make persistent a {}? ...

Python No Longers Sees MySQLdb

Whilst writing working my way through a list of scripts I need to write I started using the MySQLdb package. This all worked fine in my Terminal by doing a simple python at the command line then import MySQLdb. However after about 30 minutes I figured I better move this to Eclipse incase I start making some stupid mistakes... Eclipse for...

PyGTK Window not hiding when told to

In my PyGTK application, I am asking a user to find a file so that operations can be performed on it. The application asks the user for the file, and relays that filename to the necessary methods. Unfortunately, when calling the gtk.dispose() method on that dialog, it just hangs there until the method being called upon to perform the f...

Django script add field to database

I added a slug field to my database and now need to go through and add those. I want to run a script that looks at the slug field in the database and if empty generates and saves. Here is what I thought was along the lines, but is not working. from project.apps.tracks.models import * def process_slug(): if not track.slug: ...

What's the meaning of '@' in python code?

Reading some Python (PyQt) code, I came across as follows. @pyqtSignature("QString") def on_findLineEdit_textEdited(self, text): self.__index = 0 self.updateUi() How does this @pyqtSignature work? How Python treat this @? ...

How to read String in java that was written using python’s struct.pack method

out.write( struct.pack(">f", 1.1) ); out.write( struct.pack(">i", 12) ); out.write( struct.pack(">3s", "abc") ); how to import struct package in java it says .. no package found when i am trying to execute it so kindly tell me any suggestions if any Thanking you i took that code from http://stackoverflow.com/questions/1255918/...

How to call process by name or tags in python

I am using multiprocessing module. This module is works on Queue that is its pick random process and assign the entery from Queue. I want to decide which process will work on which entry of Queue Here is my requirements, I will pass 2 parameters to queue Initiator Process name Action/method ( What process is going to do) Its sh...

python - appending different columns from a file to different lists?

Hi, I have a tab-delimited file as below: A 3 A 6 B 6 B 9 C 0 C 2 I wish to read the file in as below: LIST = [['A', '3'], ['B', '6'], ['C', '0'], ['A', '6'], ['B', '9'], ['C', '2']] The order is not important. I am only concerned that each row is read in increments of two and assigned to a sub list. An...

How do I convert a tuple of tuples to a one-dimensional list using list comprehension?

I have a tuple of tuples - for example: tupleOfTuples = ((1, 2), (3, 4), (5,)) I want to convert this into a flat, one-dimensional list of all the elements in order: [1, 2, 3, 4, 5] I've been trying to accomplish this with list comprehension. But I can't seem to figure it out. I was able to accomplish it with a for-each loop: myLi...

Making HTTPS Requests in Twisted

I am trying to write a client that can make both HTTP and HTTPS requests depending on how it is configured. For normal HTTP, I have been using twisted.web.client.Agent and using agent.request(METHOD, HOST, HEADERS, CONTENT) to make the requests. What I care about is that host field, when I do HTTP it works doing something like "http://lo...

how to change any data type into a string in python

how to change any data type into a string data in python, and store it as a string variable ...

how to check if a file is a directory or regular file in python?

how to check if a file is a directory or regular file in python? ...

How do I implement something like Digg Swarm in PHP or Python?

http://labs.digg.com/swarm/ ...

HTTP based authentication/encryption protocol in a custom system

We have a custom built program that needs authenticated/encrypted communication between a client and a server[both in Python]. We are doing an overhaul from custom written Diffie-Hellman+AES to RSA+AES in a non-orthodox way. So I would be very interested in comments about my idea. Prequisites: Klient has a 128bit RegistrationKey which ...

Variables in Python - a simple question...

Hello - I'm a novice Python user trying to do something that I think should be simple but can't figure it out. I've got 2 variables defined: a = 'lemon' b = 'lime' Can someone tell me how to combine these in a new variable? If I try: >>> soda = "a" + "b" >>> soda 'ab' I want soda to be 'lemonlime'. How is this done? Thanks! ...

binding generic c++ libraries to python with boost.python

I would like to know what's the process, when binding C++ libraries that are written with in a generic way. Is there a posibility of binding a template class, or you can only bind only a template generated class ? ...