@w03_ recursive functions are fun. Once you’ve figured them, closures and first-class functions out you’re pretty much there :)
@w03_ recursive functions are fun. Once you’ve figured them, closures and first-class functions out you’re pretty much there :)
Anyone wanting to build a #microformats2 parser in #python? I’m up for helping out, drop into IRC and mention it
django.test.TestCase
and subclasses don’t warn you if the fixtures specified in their fixtures
list don’t exist — double check naming if your tests mysteriously start failing or run suspiciously quickly
Want to easily send webmentions from the command line, or from bash/python scripts? @vrypan made a neat little package to do just that: github.com/vrypan/webmention-tools
pip install webmentiontools
webmention-tools urlinfo http://waterpigs.co.uk/1000
webmention-tools send source target
Watch out for #python dict-based string interpolation examples which look like this:
'Hello, %(name)s' % {'name': 'Otter'}
That s
after the brackets isn’t pluralising one adorable aquatic mammal into a whole bunch of them, it’s actually part of the interpolation placeholder — the equivalent of
'Hello, %s' % 'Otter'
Note also that for some reason, python lets you put spaces between the closing bracket and the type signifying character. This can cause extremely weird bugs when the string being interpolated is also being translated. For example:
_('%(customer) shared a thing') % {'customer': 'Mr. Bean'}
If not translated, this will produce this confusing but fairly easy to debug output
'Mr. Beanhared a thing'
But if 'shared' is translated into a word beginning with, for example, d
, you’ll just get an exception like TypeError: A float is required
There doesn’t seem to be a decent minimal, standalone websockets server for #python, and #golang doesn’t have a simple way of accessing I2C devices. Looks like I might finally have to jump on the nodejs bandwagon for my #raspberrypi schenanigans.
Also in #raspberrypi today: learning about I2C communications. Tips+resources:
sudo
sudo i2cdetect
before and after plugging it in and see which address changedi2cdump
, i2cset
and i2cget
, they’re super useful for poking around in I2C devicesI cobbled together a #python class for communicating with the ADXL345 by cross-referencing between the Arduino library for that chip and Adafruit’s I2C library, only to find that someone else had done so only hours earlier!
I get a little annoyed at #python every now and again (grr package management) but then I come across things like nested tuple unpacking which are just so lovely they make up for it:
for i, (key, value) in enumerate(list_of_tuples):
print i, key, value
@briansuda just playing around with SimpleCV, looks like working with Kinect depth data is extremely easy! tutorial.simplecv.org/en/latest/examples/kinect.html
Loving Django’s prefetch/select_related
— that, along with a few small changes, reduced a task which was taking > 500,000 queries to 4558
#django tip: if you come across weird inconsistencies between apps when trying to serve static files in dev, run with runserver --insecure
even if you have DEBUG=True
when-changed is a really nice little #python script for running a command whenever any file(s) change /by johj
Spent ~3 hrs with the office arduino+ethernet shield and my old favourite pyo and I’ve got a light/flex controlled synthesiser over OSC. I dread to think how many weeks it would have taken me to implement this on a PIC.
#learning Django
Building a document templating and styling system in #python. Been meaning to do this for a long time, finally the awkwardness of using indesign for my contracts, invoices and estimates has become too stupid
Diaspora Export: Quickly generate a JSON file of all your public #diaspora posts #indieweb #ownyourcontent
php2python.com is super useful for learning all the little things which always need doing when moving from #php to #python, e.g. splitting a string using another string, or pretty-printing a dict.
Doing some wxPython programming. “Menu” is one of those words that, when you look at it properly, looks really weird :s
Pyo tip: Turn down the master volume if you’re getting nasty scratches + pops in your recordings