Here's a small utility to generate QR code image using Google Charts API.
Note the hand crafted Python 2/3 support, for more advanced stuff you might want
to have a look at six. However for
this script I wanted to stay without external dependencies.
Wednesday, November 26, 2014
Sunday, November 16, 2014
"Experience is the name every one gives to their mistakes."
- Oscar Wilde
- You forgot to import a module
- You made a typo
AttributeError: 'NoneType' object has no attribute ...
- You forgot a return in your function
- Typo on dot lookup (obj.foo)
- Object is different type from what you think (str vs int)
- Object does not implement a dunder method (e.g. __len__)
There's also the 3'rd party didyoumean module, which might be interesting for beginners. It changes the default stack trace to add a hint about what might be the problem.
Posted by Miki Tebeka at 07:32
Monday, November 03, 2014
I was teaching a course on "Python Analytics" (pandas, scikit-learn, matplotlib ...) and was asked to provide an example of streaming chart - ones that updates periodically. I''ve showed a couple of examples one by generating image using matplotlib and another with bokeh-server. After a couple of days I remembered another way - using flot to render the chart. Here''s a small example using Flask as the web server (the code works both on Python 2 and 3).
- Don''t use debug=True in production :)
- For simplicity everything is in one file. However for larger application you might want to take the HTML template(s) out
- Data is in memory, a restart will wipe it out. If you need data persistence - pick a database (shelve, sqlite3 ...)
- A big shoutout to Continuum Analytics - Anaconda (and conda) has made my life so much easier teaching this workshop.
Posted by Miki Tebeka at 19:28
- ► 2016 (17)
- ► 2015 (18)
- ▼ November (3)
- ► 2013 (35)
- ► 2012 (22)
- ► 2011 (29)
- ► 2010 (17)
- ► 2009 (38)
- ► 2008 (45)
- ► 2007 (26)