skip to content | skip to sidebar

Python string interpolation trick

December 7th, 2008

Today, I will show you a trick that may help you with the heavier string formatting jobs in Python.

Most people using Python know how to format output using string interpolation. It works much like C’s sprintf, except for the funny % operator:

>>> a = "the Knights"
>>> b = "Ni"
>>> "we are %s who say %s" % (a, b)
'we are the Knights who say Ni'

What is less known is that you can replace the right hand argument by a dictionary and use its keys to tell what value goes where. That’s handy when you need to insert more than one or two in a string, or when a single value is used more than once. Especially for localisation strings, it gives you the flexibility to determine the when and where of the values in the string itself.

>>> "we are %(who)s who say %(what)s" % {"who": a, "what": b}
'we are the Knights who say Ni'

Combine that with the even lesser known function vars() which returns a dictionary of the local variables and their values:

>>> vars()
{'__builtins__': <module '__builtin__' (built-in)>, '__name__':
 '__main__', 'b': 'Ni', '__doc__': None, 'a': 'the Knights'}

Use it at the right hand, and you can simply use the variable names as keywords:

>>> "we are %(a)s who say %(b)s" % vars()
'we are the Knights who say Ni'

This probably is the closest you can get to the Perl and PHP style syntax "we are the $a who say $b".

Share and Enjoy!

The Next Big Thing, 13 Nov 2008, part 1

December 6th, 2008

Last month, I went to The Next Big Thing at Trix, a showcase night presented by Keremos. Six promising young bands on the rise populated the bill: The Galacticos, Arquettes, Steak Number Eight, Team William, Kawada and Roadburg. That much good on one night was a perfect opportunity to go and shoot some pictures. For the following three bands, I’ve been using two prime lenses: a Sigma 30mm f/1.4 and a Canon EF 100mm f/2.0.

The first band to hit the stage was The Galacticos: always in for a good show with happy rock and catchy melodies. In contrast to last time at Tank series, there was enough light at Trix to justify colour pictures. Though the excessive use of smoke made it quite difficult still. [photo series]

I’ve seen Arquettes playing before, but this was the first time I had my camera with. Though they played on the smaller stage with basic lights, I’m much more pleased with the results than of The Galacticos and Steak Number Eight. Is it the lack of smoke? Or the more static lighting flooding the stage? I’ve done quite a few black & white conversions as the red front lights almost always result in very ugly colour casts, even if you set your white balance at minimum colour temperature and drag down the red channel. But in some cases it was still acceptable. (photo series)

Next on the main stage was Steak Number Eight. I’ve seen them a number of times now and their slow and heavy wall of sound still impresses me. The seemingly mandatory thick cloud of smoke made it quite impossible to get the crisp shots I was after. And so I decided to play it a bit differently: desaturating the colours even further and upping the contrast, building up a grim atmosphere that fits their music. (photo series)

Links to complete photo series: The Galacticos, Arquettes, Steak Number Eight.

manuals on software optimization

December 5th, 2008

While looking for some info on 64 bit masm, I stumbled on Agner Fog’s site with five comprehensive manuals on software optimization. Each covers a different topic: optimizations in C/C++ and assembly, microarchitectures, instruction tables and calling conventions.

Dollarqueen @ Du Gaz, 8 Nov 2008

November 25th, 2008

After the After All gig, I rode back with Piet Focroul to Du Gaz in Bruges, where Dollarqueen was giving a show: a fairly new band but with experienced musicians, pure rock ‘n roll with a touch of blues and a hint of The Doors. Their songs just get stuck in your head (my personal favourites: The bomb and Rock ‘n roll star).

The light conditions couldn’t have been more different than on Blikfest: static and dim. Perfect conditions to try out my new Sigma 30mm f/1.4. And with a crowd as packed as in Du Gaz on that night, the wide angle 30mm was very welcome (well, technically, due to the crop factor, it actually is equivalent to the standard FOV).

Slow shutterspeeds, lots of motionblurred pictures, ugly colours only suitable for black and white. And yet, somehow I love it! I’m especially fond of the following detail of a microphone waiting on the floor with behind it a pair of feet tapping on the rhythm of the music:

Kudos to Piet for the hospitality and introduction to this wonderful band!

link to complete photo series

After All @ Blikfest, 8 Nov 2008

November 25th, 2008

A couple of weeks ago, I accompanied After All to a gig for the second time, , . And just like the previous time, it was a great experience. The venue was JC Togenblik in Beveren-Waas, Belgium of course, where the fifth edition of the Blikfest metal festival was organized. I didn’t see much of the rest of the festival, except for Thurisaz of which I also have some pictures. My only interest was to capture the trash metal attack from Bruges.

It must have been one of the first times I didn’t have to battle against dim lights. Apart maybe for the Waxdolls gig. Most shots had comfortable fast shutterspeeds. Fast enough to use my telelens and still get crisp shots of the drummer. The lack of smoke did help as well of course. There’s nothing that ruins a distant shot like a thick cloud of smoke.

So, plenty of technically successful shots to go home with, and many have ended up in the gallery. Maybe too many. But somehow, I can’t help feeling they don’t have quite the same ring as my other shots. It’s almost like they are too clean … No smoke gives you crisp shots, but at the same time you loose colourful backgrounds. Instead, you get a dull black hole. Still, I have one favourite shot, which is this black and white one:

At any rate, I had a great time, begging for more. Here’s to After All, thanks for the hospitality and the ride, it is much appreciated!

link to complete photo series

Waxdolls @ Vijverpop 2008

July 10th, 2008

The night after Best of the West (see previous post), two members of QuiOui performed at Vijverpop as the Waxdolls. They are called the electropunk revelation of Bruges or Ghent (depends on who’s reporting it =), and they definitely have a bright future ahead.

Waxdolls @ Vijverpop 2008 (by Bram de Greve)

Vijverpop is a festival organised by a school in Bruges. Though it is a very small festival, it cleary showed what difference it makes when there’s enough light and a bit of smoke. Enough light means you can shoot at faster shuttertimes and have more pictures that are sharp and well exposed. With a bit of smoke, you get nice colours all over your image instead of ugly walls and ceilings.

Being very pleased with the colours, I didn’t even try to convert to black and white. Instead, I even increased the local contrasts and colour saturations to give it extra punch. It does fit the electropunk better, I think.

link to complete series

Best of the West …

July 9th, 2008

It’s been exactly two months ago that I’ve followed QuiOui for a second time to a concert. But somehow, I’ve only now managed to get all pictures online … Place to be was JC Ten Goudberge in Wevelgem. The concert bill featured all medallists of Westtalent 2007: Low Vertical, QuiOui and Steak Number Eight.

QuiOui @ Best of the West, 9 May 2008 (by Bram de Greve)

The lighting conditions were difficult at best. Two stands with four spots each in impossible locations with colour combinations of which I didn’t know they existed. For Steak Number Eight, they altered it to mainly reds with some spots on the floor behind the drums. Which was actually very cool to see, but possibly even worse for picture taking. The f/2.8 of my 17-55mm was just too slow, and the 50mm f/1.8 was constantly hunting for focus. So at the end, taking pictures was more a matter of sheer luck.

Steak Number Eight @ Best of the West, 9 May 2008 (by Bram de Greve)

Though the pictures aren’t great in an absolute sense, there are still some that I really like. Most of them are very low key and have to build upon atmosphere rather than sharpness. In case of Steak Number Eight, I’ve tried to exaggerate this by applying an unsharp mask with a very large radius to the lightness channel to increase the local contrast.

Links to complete series: Low Vertical, QuiOui, Steak Number Eight.

Morda @ BoscoRock 2008

July 3rd, 2008

I’ve known Morda pretty much since the early days. Vague memories of some gigs in the Frontline, at the old location opposite to the Vooruit. Innerface, of the split album with Trust, still is one of my favourite tracks, on par with much of the Azerion album (which is just awesome, btw). Knowing their guitar player Doc and former vocalist VeganPietn from a distant past in KSA, it was inevitable that sooner or later, I would get them in front of my lens. The first opportunity was at BoscoRock festival in Kortrijk, where I’ve also shot Steak Number Eight (view series). Originally, Kudos was also going to perform on that festival, but they’ve cancelled.

Morda @ BoscoRock 2008 (by Bram de Greve)

The crowd was going wild, as usual, but I had got myself a nice spot in the front pit. The lights were rather basic, there was lots of white. Because of this, I was planning to go black & white exclusively. But it turned out some of the shots still have some nice colours, some ochre with a tad of blue.

Link to complete series

PS: many kudos to KSA Marke for retrieving my cellphone!

photo gallery update

June 8th, 2008

It’s been a while since I’ve posted any update my photo gallery (ignoring the band shots of Waxdolls and Kudos). The Red Rock Rally pictures, take about a month ago, are finally uploaded now. My friends from Kudos participated in the contest and went home with the audience award. I feel a bit bad about this delay, but now everything is getting up to speed again. There are three sets of pictures: the headliners of the night Balthazar and Absynthe Minded, and of course Kudos.

Absynthe Minded @ Red Rock Rally 2008 (by Bram de Greve)

A while ago I also added Steak Number Eight playing at BoscoRock, and you can expect pictures of Morda playing there very soon. Finally there are others still of QuiOui, Low Vertical, Steak Number Eight again, and Waxdolls from other gigs … phew!

PS: kudos to lyc, no pun intended.

Band shots: Waxdolls and Kudos

June 3rd, 2008

By popular demand, here are two band shots I’ve taken. I not usually do band shots like this (in fact, these are the only two), as I’m more comfy with natural/candid shots.

The first one is of the electro punk duo Waxdolls. It was taken at Cultuurkapel De Schaduw, after the Quioui gig.

Waxdolls, 18 April 2008 (by Bram de Greve)

The second one is of the rock band Kudos, a few days after they’ve won the audience award at Red Rock Rally. The local newspaper Brugsch Handelsblad was going to feature an article, and they needed a band shot. As I hadn’t any good ones from the gig, I went to their rehearsal space a few days later to shoot this one. The same article was also published in the local edition of Het Nieuwsblad. At any rate, this is my first published picture =)

Kudos,7 May 2008 (by Bram de Greve)