What's the best way to assemble Javascript modules server-side in Python?
For one of my projects I simply wrote a small build script which handles both CSS and JS files.
For JS it reads the list of JS files from a text file, concatenates all scripts and submits them to google for minification.
For CSS I take my central CSS file and recursively replace all @import statements with the referenced file (since i only use absolute paths no path rewriting is necessary); after this I have a single CSS file which is then run throuh cssmin.
Since you are using Django you could probably write such a script in a way to make it easily callable through manage.py
I'm planning an extensible web app where base objects are extended by JavaScript modules which plug in. Each JavaScript object may just be an independent bit of code, or I might be building a large object to simulate a module namespace. I'll be using a Django back-end and Backbone.js, since you asked.
The system should be easily modular, so adding a new module should be a question of just dropping in another file or database row or whatever. The person installing the module shouldn't have to edit a large JavaScript file manually (or run a special script, in an ideal world).
I have two options: just serve each JS file separately or get the server to assemble them. The first option will get ungainly when a large number of plugins is reached. 
I'm looking into the best way to implement the second option: assembling a JavaScript file from a lot of small JavaScript snippets. I could just do some blind string concatenation, but there may be a Python library that can do this and take account of problems I haven't foreseen.