The Python programming language excels in scope and in pre-compilation, and is very useful for object-oriented scripting. This makes it suitable for larger projects than would otherwise be handled through scripting languages.
- Adding links to PDF in Python
- It is very easy to add links to PDF documents using reportlab or platypus in Python.
- Apple goes to the Swift
- The most exciting part of the WWDC keynote last Monday wasn‘t the new operating systems for the Macintosh and iDevices. It was the announcement of the new Swift programming language for MacOS and iOS. A new programming language is my equivalent of “one more thing…”
- appscript AppleScript translator
- Those of us who like Applescript but want a solid command-line scripting environment no longer have to muddle through when using appscript. We can write in AppleScript and then translate to appscript.
- Astounding Scripts on Monterey
- Monterey removes Python 2, which means that you’ll need to replace it if you’re still using any Python 2 scripts; there’s also a minor change with Layer Windows and GraphicConverter.
- Automated Scribus Daredevils NPC character sheets
- Part 2 of 2: the free Scribus page layout software makes it easy to automate the creation of NPC character sheets.
- Automatically distributing images within XHTML
- One of the nice things about XHTML is that the tools for reading XML have finally matured. So if, for example, I want to have a series of images automatically placed within my web page, I can parse the XHTML of the content to ensure that nothing is broken.
- Automatically link related URLs in Django
- One of the features of my old blog and my new Django CMS is autolinking the URLs that I mention in the text.
- Caching DTDs using lxml and etree
- It’s not just a good idea to cache public DTDs when validating your web pages with an automated script. If you don’t do it, you might get blocked from w3.org.
- Calculate poster pixel sizes from an existing image file
- This script takes a height and a width in whatever units you wish, an existing set of pixel dimensions for an image file, and calculates which pixel dimension should be cropped to match the poster size.
- Calculating true three-fold PDF in Python
- Calculating a true three-fold PDF requires determining exactly where the folds should occur.
- Catalina: iTunes Library XML
- What does Catalina mean for 42 Astounding Scripts?
- Cleaning iTunes track information
- Python and appscript make it easy to modify iTunes track information in batches—if you’re willing to get your hands dirty on the Mac OS X command line.
- Custom authentication in Django
- Decorators can be used to restrict access to any view.
- Daredevils NPC generator
- Part 1 of 2: a script to calculate Daredevils attributes, talents, skills, and stats from a text file of initial values and character development.
- DieSquare for iOS
- Are your dice biased? Perform on-the-fly chi-square tests using your iPad or iPhone and Pythonista.
- Django forms and edit_inline models
- Getting edit_inline models to show up on custom forms isn’t as hard as it looks. MultiValueField and MultiWidget aren’t documented well, but they do work. Here’s how I did it in Django 0.96.
- Django Twitter tag and RSS object
- I wanted to embed my twitter feed into my Django blog, and didn’t see any simple RSS readers for Python that did what I wanted.
- Django: Beyond the SQL
- Django is a great application framework for Python and web applications. You can use it to greatly speed up your database and application development both on the web and on the command line. This tutorial is currently a very rough draft; it probably won’t be very useful without the assistance of someone who knows Django running the tutorial. If I ever run this tutorial a second time, I’ll probably update it with screenshots to make it more usable for individuals.
- Draw a circle on an iPad map from three points in Pythonista
- Use Pythonista on the iPad to import a map screenshot, tap three points, and draw a circle from those three points. This simple shell can be used for other on-the-fly programming, too.
- Dynamic template content in Django fields
- It’s easy to run database content through Django’s templating system as if it were a template, before handing it off to the “real” template render. This allows you to put template tags inside of your dynamic content as well as inside template files.
- Easier random tables
- Rather than having to type --table and --count, why not just type the table name and an optional count number?
- Embedding Mako into Django
- You got Mako in my Django! You got Django on my Mako! Two great templates that template great together.
- Excerpting partial XHTML using minidom
- You can use xml.dom.minidom to parse partial XHTML as long as you use a few tricks and don’t mind that getElementById doesn’t work.
- Goodreads: What books did I read last week and last month?
- I occasionally want to look in Goodreads for what I read last month or last week, and that currently means sorting by date read and counting down to the beginning and end of the period in question. This Python script will do that search on an exported Goodreads csv file.
- How useful is Django?
- I was recently asked “how do you find Django?” after mentioning that I’ve been using it extensively. The answer is by squinting a bit.
- Learning Python
- If you’ve been looking to learn Python, or need a new language with clearly defined scope and easy objects, this is an extremely useful book.
- Less primitive Model 100/200 Data Transfer Script
- I’ve managed to refine my primitive Linux data transfer script into a script that I use nearly every day to transfer files to and from my Model 100/200.
- Media duration in Python on Mac OS X
- It turns out to be very easy to get the duration of MP3 files, MPEGs, and other media files on the OS X command line.
- minidom self-closes empty SCRIPT tags
- Python’s minidom will self-close empty script tags—as it should. But it turns out that Firefox 3.6 and IE 8 don’t support empty script tags.
- Multiple column PDF generation in Python
- You can use ReportLab’s Platypus to generate multi-column PDFs in Snakelets, Django, or any Python app.
- Multiple Input Fields with multiple inheritance
- We needed to display one TextField as either a TextInput or a Textarea, depending on the value in the field. Multiple inheritance makes it easy, if a bit wonky.
- Multiple tables on the same command
- The way the “random” script currently stands, it does one table at a time. Often, however, you have more than one table you know you’re going to need. Why not use one command to rule them all?
- MySQL for Other Applications
- The basics of working with MySQL for users of other applications such as Dreamweaver, PHP, Perl, or Python.
- Object-oriented HTML with Python
- Simple HTML creation within Python scripts, using a hierarchical organization of HTML parts.
- Parsing JSKit/Echo XML comments files
- While I’m not a big fan of remote comment systems for privacy reasons, I was willing to use JSKit as a temporary solution because they provide an easy XML dump of posted comments. This weekend, I finally moved my main blog to custom comments; here’s how I parsed JSKit’s XML file.
- Percentage-based random tables
- Our current random item generator assumes that each item shows up as often as any other item. That’s very OD&D-ish. But AD&D uses percentage dice to weight toward some monsters and items more than others.
- A present for Palm
- Palm needs a little help understanding XML.
- Primitive data transfer script for the Model 100/200
- This script is basically just a very simple BBS, for transferring data to and from a Model 100/200 over an RS232 serial connection.
- Programming for Gamers: Choosing a random item
- If you can understand a roleplaying game’s rules, you can understand programming. Programming is a lot easier.
- Put a relative clock on your Desktop with GeekTool
- There are a lot of desktop clocks that show the absolute time. But sometimes you just want to know if the time is today, or yesterday, or two days ago. Here’s how to do it with Python and GeekTool.
- Python command-line option parser
- As of Python 2.3, there is a very easy to use command-line option parser to replace getopt.
- Python Imaging Library on Leopard Intel
- On Mac OS X Server 10.5, Apache runs as a 64-bit process, but wants to compile everything as 32-bit. This makes it difficult to install many modules; here is how to get the Python Imaging Library working for Django projects such as photologue.
- Python PDF generation with Snakelets
- One of the things I need to do to move my current web site over to Django is be able to automatically generate PDF documents. Step is to learn how to generate PDF using Python.
- PyTown
- General rambling in code regarding Python, Mailman, and Django.
- Quick & dirty Snakelets “blog”
- This “No Second Chances” blog engine was fun to write during spare time at ETech 2007. Snakelets appears to be a useful Python webapp server if you need a webapp server immediately.
- Quick-and-dirty old-school island script
- Here’s a Python-based island generator using the tables from the Judges Guild Island Book 1.
- Retry SSH connections after transient error
- The timeout class set up the concept of retrying after a specified timeout period, but why not retry on other transient errors?
- Save all Scribus pages as EPS
- There doesn’t appear to be a built-in way to save all pages seperately as EPS in Scribus. This script will do so.
- Test classes and objects in python
- One of the advantages of object-oriented programming is that objects can masquerade as each other.
- Thinking Python: Django cache expiration time
- Django sets the expiration time when data is cached. Sometimes it makes more sense to expire data dynamically based on later changes to the database. Does this mean a change to CacheClass? Not necessarily.
- Timeout class with retry in Python
- In Paramiko’s ssh client, timeouts don’t seem to work; a signal can handle this—and then can also perform a retry.
- Using appscript in Python to control GUI applications
- The appscript module for Python lets you control scriptable applications on the command line without having to coordinate your command-line script with your Applescript applications.
- Using appscript with Apple Mail to get emails and attachments
- Python and appscript can be used to get email messages out of Apple’s OS X Mail client, and even to get and save attachments.
- Using ETag and If-Modified-Since
- In the article on grabbing an RSS feed, I mentioned that if you’re grabbing a feed more than once a day, you should pay attention to the ETag and the If-Modified-Since headers. Here’s how to do that.
- Using the color picker in Inkscape extensions
- It was pretty easy, looking at the built-in extensions, to switch colors from one to another if I wanted to type their values by hand. But using the color parameter type took a bit of sleuthing.
- What app keeps stealing focus?
- I’ve been having a problem on Mac OS X with something stealing focus. Here’s how to at least find out what that something is.
- Write an Inkscape extension: create multiple duplicates
- Once you get past the complete lack of simple real-world examples, it’s pretty easy to make Inkscape extensions. So, here’s a simple real-world example.
More Information
- Django
- “Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.” Oh, the sweet smell of pragmatism.
- Python 2.7
- “Python 2.7.18 is the last release of Python 2.”
- Pythonista
- “Bring the Zen of Python to iOS.”
- Python, Unicode and UnicodeDecodeError
- If, like me, encode/decode confuses the hell out of you in Python, you’ll find this article by Dan Fairs useful. The summary: encode goes from Unicode to a specified encoding; decodes goes from an unknown encoding to Unicode. This is why both decode and encode require you to specify the non-unicode encoding. With decode() you’re specifying what the current encoding is that needs to be transformed into Unicode. With encode() you’re specifying what you want the Unicode to be transformed into.