Bubble Foundry


Posts tagged with: Python

option.py
Because my hobby seems to be writing Option libraries in various languages, I’ve written another, in Python: option.py. Enjoy. Read more – ‘option.py’.
Python-style in in Scala
Because hey, why not? In Python: >>> 1 in [1, 2, 3] True In Scala: class In(a: Any) { def in[T](s: Seq[T]) = s.contains(a) } implicit def any2In(a : Any) = new In(a)   scala> "a" in List(1, 2, "a") res0: Boolean = true   scala> "a" in List(1, 2, "b") res1: Boolean = false Read more – ‘Python-style in in Scala’.
Mobile APIs Talk Next Wednesday
Daniel Salber and I will be giving the next Appsterdam Weekly Wednesday Lecture on mobile APIs. The talk is on Wednesday July 27 at 12:30 at Vijzelstraat 20, Amsterdam. Here is our talk description: Many mobile apps get data or send data to a server. What are the issues in implementing this kind of apps? […] Read more – ‘Mobile APIs Talk Next Wednesday’.
Setting Locales in Python
You can use locale to localize things like Python’s datetime module. However, its defaults aren’t always the nicest. For instance, for Dutch is defaults to ISO while I prefer UTF-8: >>> locale.setlocale(locale.LC_ALL, 'nl_NL') 'nl_NL' >>> locale.getlocale() ('nl_NL', 'ISO8859-1') >>> locale.setlocale(locale.LC_ALL, ('nl_NL', 'utf8@euro')) 'nl_NL.UTF-8' >>> locale.getlocale() ('nl_NL', 'UTF8') As you can see, for some reason ‘utf8@euro’ […] Read more – ‘Setting Locales in Python’.
Types in Python
There are many great things going for Python but I find its type system to be rather wonky. Most people will direct you to use the type() function to determine types: >>> type([]) <type 'list'> >>> type([]) == type(list) False >>> type([]) == type(list()) True >>> type([]).__name__ == 'list' True However, in everyday use isinstance() […] Read more – ‘Types in Python’.
Introduction to the AnyMeta API
Recently I’ve been working on a project for Mediamatic (hopefully more later)  and a key part of my work involves using the REST API for their AnyMeta community management system. Unfortunately there isn’t a lot of documentation out there either for AnyMeta in general or for its API in specific. There’s the user guide if […] Read more – ‘Introduction to the AnyMeta API’.
Imajs
I made this a month or two ago but I forgot to mention it here: Jacob Biljnai of Tumblr was complaining on Twitter that there wasn’t a Javascript-based image resizing API so I made him one using App English, Imajs. Enjoy. Read more – ‘Imajs’.
Installing Twisted on OS X
I’m using Twisted for a project and the default sudo easy_install twisted was giving me errors. It turns out that my default Python install, via Fink, was built for the i386 architecture while Twisted was trying to link to its libraries using the x86_64 architecture, for which it does not have libraries built. sudo ARCHFLAGS='-arch […] Read more – ‘Installing Twisted on OS X’.
Fun with Scala Implicits
Last night I discovered that Scala’s RichString has a format method quite similar to  Python’s. However, in Python I’m used to using the % operator and I wondered if I could use the same syntax in Scala. With a little library pimping and help from my friends on Stack Overflow, I can: class BFString(s: String) […] Read more – ‘Fun with Scala Implicits’.
Simple Fun with Python’s Datetime Libraries
My Apple iPhone Developer account expires in 56 days, so I wanted to know what expiration date I should mark in my calendar. Here’s how I calculated it from the Python console: >>> import datetime >>> datetime.date.today() + datetime.timedelta(days=56) datetime.date(2009, 11, 8) Read more – ‘Simple Fun with Python’s Datetime Libraries’.