python

Python unhash value

Hi all I am a newbie to the python. Can I unhash, or rather how can I unhash a value. I am using std hash() function. What I would like to do is to first hash a value send it somewhere and then unhash it as such: #process X hashedVal = hash(someVal) #send n receive in process Y someVal = unhash(hashedVal) #for example print it print so...

load a pickle file from a zipfile

For some reason I cannot get cPickle.load to work on the file-type object returned by ZipFile.open(). If I call read() on the file-type object returned by ZipFile.open() I can use cPickle.loads though. Example .... import zipfile import cPickle # the data we want to store some_data = {1: 'one', 2: 'two', 3: 'three'} # # create a zipp...

how to speed up the code??

in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation. I approximatily need to call this method about 10,000 times.which is making my program very slow? any method for handling this files in a be...

Python Library installation

Hi everybody I have two questions regarding python libraries: I would like to know if there is something like a "super" python library which lets me install ALL or at least all scientific useful python libraries, which I can install once and then I have all I need. There is a number of annoying problems when installing different libra...

Error in Python's os.walk?

The os.walk documentation (http://docs.python.org/library/os.html? highlight=os.walk#os.walk), says I can skip traversing unwanted directories by removing them from the dir list. The explicit example from the docs: import os from os.path import join, getsize for root, dirs, files in os.walk('python/Lib/email'): print root, "consu...

Python module for drawing functions graphics

Hi all, Which python module should I use for drawing simple functions graphics? E.g f: M -> M, f(x) = x ...

python `IN` module problem (FreeBSD)

I'm trying to work with sockets and I have such problem In code example: setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0') I have error AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE' On Linux machine this attribute is OK but on FreeBSD trere are no any SO_* attributes in module IN. What...

Python: Preserve file attributes in ZipFile

Hello. I'm looking for a way to preserve the file attributes (eg. read-only) of a file that gets written to a zipfile.ZipFile instance. The files I add to the zip archive gets their file attributes reset, eg. the read-only flag is gone when inspecting the archive with zip applications and after unzip. My current environment is Windows...

Xml comparison in Python

Building on another SO question, how can one check whether two well-formed XML snippets are semantically equal. All I need is "equal" or not, since I'm using this for unit tests. In the system I want, these would be equal (note the order of 'start' and 'end'): <?xml version='1.0' encoding='utf-8' standalone='yes'?> <Stats start="12759...

Using localtime in a where clause for GqlQuery

I'm trying to understand how I can use the local server time to quickly filter results on google appengine. It seems to me that there should be a simple way of doing this using DATETIME(time.localtime()). For example (where 'timestamp' is of type db.DateTimeProperty)... q = db.GqlQuery("SELECT * FROM LiveData WHERE timestamp > DATETIME...

how to speed up code??

i want to speed my code compilation..I have searched the internet and heard that psyco is a very tool to improve the speed.i have searched but could get a site for download. i have installed any additional libraries or modules till date in my python.. can psyco user,tell where we can download the psyco and its installation and using pro...

ldapsearch and vcard creation

I'm using openldap on Mac OS X Server 10.6 and need to generate a vcard for all the users in a given group. By using the ldapsearch I can list all the memberUid's for all users in that group. I found a perl script (Advanced LDAP Search or ALS) that was written by someone that will generate the vcard easily. ALS can be found here http://w...

Convert list of lists to one list

Possible Duplicates: Flattening a shallow list in python How flatten a list of lists one step I didn't find any other question, so here it is: I have a list of lists of objects of the same type like this: [[a,b,c],[d,e,f]] i want: [a,b,c,d,e,f] there's probably an easy way doing this, but i'm kind of stuck. ...

Python: Decent config file format

I'd like to use a configuration file format which supports key value pairs and nestable, repeatable structures, and which is as light on syntax as possible. I'm imagining something along the lines of: cachedir = /var/cache mail_to = [email protected] job { name = my-media frequency = 1 day source { from = /home/michael/Imag...

mod_python can't see my Django project settings file

Hey, I need to deploy my Django application on my apache server, I've added the following to my httpd.conf: <Location "/dashboard/"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/home/firas/project/trunk/dashboard/analytics','/home/firas/project/trunk/dashboard', '/home/firas/project/...

Use Python to search one .txt file for a list of words or phrases (and show the context)

Basically as the question states. I am fairly new to Python and like to learn by seeing and doing. I would like to create a script that searches through a text document (say the text copied and pasted from a news article for example) for certain words or phrases. Ideally, the list of words and phrases would be stored in a separate file...

Is there a way to programatically access a bazaar repository?

I would like to access a bazaar repository and pull code from it with either a Python or PHP script. How is this done? Is there a Python module / PEAR library that makes this easy? If it helps, the repository is on Launchpad. Edit: As mentioned below, running the bazaar commands directly is not an option. Also, an example would be muc...

In Python, how do I search a flat file for the closest match to a particular numeric value?

have file data of format 3.343445 1 3.54564 1 4.345535 1 2.453454 1 and so on upto 1000 lines and i have number given such as a=2.44443 for the given file i need to find the row number of the numbers in file which is most close to the given number "a" how can i do this i am presently doing by loading whole file into list and co...

i need powerful interactive packet manipulation program like scapy

i need powerful interactive packet manipulation program like Scapy for Ruby please help ...

Python version 2.6 required, which was not found in the registry

Can't download any python Windows modules and install. I wanted to experiment with scrapy framework and stackless but unable to install due to error "Python version 2.6 required, which was not found in the registry". Trying to install it to Windows 7, 64 bit machine ...