Python Weekly

Follow this link and sign-up for the newsletters if you have an interest in python. Their weekly newsletter/email always contains at leasst one article that is interesting and educational Find it here »

Taking advantage of *args and **kwargs

Taking Advantage of *args and **kwargs I consistently forget the option word I have included in a function and so I had to design a way to accept different keywords (option) names to trigger features with in a function. As an example, assigning a color to a box border is very easy by just adding something like this to a function’s arguments: ’’’ def buildabox(msg, border_color=“red”): """ docs go here to put a box around msg """ … ’'' »

Python's all() function

Python all() function Much of my coding efforts are directed towards analyzing financial data specifically targeting potential cash secured puts or covered calls. Recently, I had to refine some market overview displays. I needed a listing of the current market “gainers” and market “losers”. There is one site which I scrape using panda read_html function to grab a hadful of tables. My problem arises from two factors. One is there are no labels or titles to the tables and they can vary. »

Sometimes It Is The Obvious

This was one of those “problems” that nagged me for many hours until the obvious dawned on me. I wrote a python script to grab the temperature and humidity from a DHT22 sensor and then write the output with the proper syntax to send to my monitoring program [xymon]. The wrapper bash script ran every 5 minutes and used a redirection to write out a file ie:

*/5 * * * * /usr/local/bin/ >/tmp/temphum.dat

The wrapper script grabs output and sends it to the server. Having this wrapper script lets me run the python script independently for testing or for curiosity.