By José Lopes
Though the Python math library has the linear interpolation that, if I'm not mistaken,
requires the adjacent points to the point we need the interpolation, I created my own function to do it.
I did it because I needed to do many interactions where the adjacent points changed, and also because
I failed to check first if Python had the linear interpolation function!
With this post I share my solution to anyone interested. It may come in handy if you are calculation several points with a bunch of initial data. Have a look!
By: Helder Guerreiro.
In the last year and a half I've been programming (very slowly I admit) a web mail client written in Python. The objective is to have more or less the same feature set that Squirrelmail has.
You can check the result of my efforts here. Please be advised that this software is on its early stages and far from complete, it was only tested with Cyrus IMAP which is a very standard compliant IMAP server, so, if you test the program with other less compliant servers it may fail to work.
By now you've guessed that I'm using the IMAP server as the backend storage system for the web mail client. Since the IMAP server responses are symbolic expressions (s-exp for short) I needed a fast enough scanner to be able to parse the server responses. Note that this responses can be a bit lengthy and complex.
I'll try to show how I've solved this problem in the context described above.
Posted by José Lopes.
How to fix an error like:
ImportError: Bad magic number in ../SOME_FILE.pyc
Posted by José Lopes.
If you are using ReportLab to generate graphics you may find necessary to costumize the label axis to show only some of the entries, in order to get a more readable graphic.
The solution I propose is simple.
Posted by José Lopes
If you get the following error message when you execute a function with Python:
RuntimeError: maximum recursion depth exceeded
It means that the recursion limit of your platform was exceeded, but this can be easily fixed.
Posted by José Lopes
If you are doing a lot of calculations with one specific function, it may be interesting that it remembers the previous results so it may return them once asked gaining considerable computation time.
To do this we can do what is called memoization. This concept has nothing to do with memory in the sense of hardware but with the capacity to recall already calculated results.
Posted by José Lopes
You may need to know the for a certain function the time it takes to be executed.
The reasons for this can be, for instance, to optimize the function or check the fastest solution to a problem among severel.
This post provides a generic solution to check a function execution time.
Posted by José Lopes
This post shows a range of solutions to find the maximum value of a set of lists, and the minimum value by analogy.
Supose, as an example, that you have the following lists:
A = [1, 2, 9] B = [100, 50, 75] C = [6, 2, 80] D = [42, 33, 5]
We want to get 100 as the maximum and 1 as the minimum values.
Posted by José Lopes
When you run py2exe for a small Python program you may notice that the file library.zip it's
too big.
This may cause some problems if you're planning to make a distribution.
This post explains why and how to minimize this file size.
Posted by José Lopes
It may happen, after using py2exe several times with different projects, that the exe files get an error but the equivalent python files run without problems when executed from a shell.
Your last project runs without any problem but an older one that you just changed gives you this problem.