Skip to content
Advertisement

Reversible hash function?

I need a reversible hash function (obviously the input will be much smaller in size than the output) that maps the input to the output in a random-looking way. Basically, I want a way to transform a number like “123” to a larger number like “9874362483910978”, but not in a way that will preserve comparisons, so it must not be

Python: sort function breaks in the presence of nan

sorted([2, float(‘nan’), 1]) returns [2, nan, 1] (At least on Activestate Python 3.1 implementation.) I understand nan is a weird object, so I wouldn’t be surprised if it shows up in random places in the sort result. But it also messes up the sort for the non-nan numbers in the container, which is really unexpected. I asked a related question

counting odd numbers in a list python

This is a part of my homework assignment and im close to the final answer but not quite yet. I need to write a function that counts odd numbers in a list. Create a recursive function count_odd(l) which takes as its only argument a list of integers. The function will return a count of the number of list elements that

SQLAlchemy: What’s the difference between flush() and commit()?

What the difference is between flush() and commit() in SQLAlchemy? I’ve read the docs, but am none the wiser – they seem to assume a pre-understanding that I don’t have. I’m particularly interested in their impact on memory usage. I’m loading some data into a database from a series of files (around 5 million rows in total) and my session

python: is it possible to attach a console into a running process

I just want to see the state of the process, is it possible to attach a console into the process, so I can invoke functions inside the process and see some of the global variables. It’s better the process is running without being affected(of course performance can down a little bit) Answer If you have access to the program’s source-code,

Python : terminology ‘class’ VS ‘type’

Just a simple question : when should I use the term ‘class’, and when should I use the term ‘type’ in Python ? is ‘class’ only for user-defined types, and ‘type’ for built-in types ? or now that everything is a type … should I use always ‘type’ even for user-defined classes ? … ? Answer It is more or

Interactively validating Entry widget content in tkinter

What is the recommended technique for interactively validating content in a tkinter Entry widget? I’ve read the posts about using validate=True and validatecommand=command, and it appears that these features are limited by the fact that they get cleared if the validatecommand command updates the Entry widget’s value. Given this behavior, should we bind on the KeyPress, Cut, and Paste events

Advertisement