Category Archives: python
Counting PDF pages with python only
Found this recipe – nice and lightweight: import re rxcountpages = re.compile(r"$\s*/Type\s*/Page[/\s]", re.MULTILINE|re.DOTALL) def countPages(filename): data = file(filename,"rb").read() return len(rxcountpages.findall(data)) if __name__=="__main__": print "Number of pages in PDF File:", countPages("test.pdf")
Django Developer Toolbar
A really nice tool for everyone developing Django. Together with virtual-env, django-evolution, fabric, pip and pydev it’s a pretty nice development environment. Get it here. Well – pydev is currently living a dangerous life – spent my whole afternoon hunting … Continue reading
.local is the Shit
… accidentally I stumbled about something I really wished for. User-specific site-packages (python-talk). As specified in “PEP 370 — Per user site-packages directory” a user’s home directory might now have a directory called .local which contains lib/python<version>/site-packages and also bin/. … Continue reading
Python + TAPI-madness
If it comes to lower- to medium-class telephony, TAPI is everywhere. Since Version 3.0 TAPI is okay, but even though controllable via COM, I was not able to use pythons win32com module to make it do what I want (here … Continue reading
Getting Birthdays out of the AppleAddressBook
Recently I posted a terrible piece of AppleScript, but I refurbished the whole thing and rewrote it in python. Basically there are two known ways of accessing the contents of the Apple AddressBook – well, two sane ways. The first … Continue reading
Double- vs Single-Quotes
In Python, I just learned, they mean exactly the same (which is a terrible waste of semantic possibilities *g*).