Python resources

General Python resources:

Python.org
Official website for the Python programming language.
Python Reference Manual
Describes the syntax and "core semantics" of the language.
Python Library Reference
Describes the standard library that is distributed with the language and which greatly enhances its immediate usability.

Python and Django resources at Webmonkey:

Get Started with Python
Introduction to Python: what it is, core data types and a for. Basically covers chapters 1–4 of Mark Lutz's Learning Python published by O'Reilly.
Get Started with Django
Django is a web framework written in Python. This is lesson one of six.
Install Django and Build Your First App
Lesson two of six
Use URL Patterns and Views in Django
Lesson three of six
User Templates in Django
Lesson four of six
Integrate Web APIs into Your Django Site
Lesson five of six
Build a Microblog with Django
Lesson six of six
Python posts in the Webmonkey blog

CAST()ing a sort in MySQL

I was asked to sort a table of lease data by floor in descending order today—simple, right? But after updating the query with ORDER BY floor DESC, I noticed the results were wrong. The 9th floor was always at the top and the 10th floor and above were between the second and first floors.

It was immediately obvious—the floor field was not stored as numeric data, but as character data. This struck me as odd, so I investigated the DB structure and values. The floor field was definitely being stored as character data, but why? The reason: the client wanted to store certain floors as LL.

So given this structure, how could I quickly and easily sort the floors? The answer: MySQL's CAST function. By casting the floor field as an integer, the numeric floors would sort correctly. Even better, the character data LL would cast to 0, preserving a correct sort.

I updated the query with ORDER BY CAST(floor as UNSIGNED) DESC and obtained the desired results. Learn more about MySQL's cast functions and operators.

Back in August, Dave Shea came up with the CSS Sprites2 technique in A List Apart No. 266. He chose to implement it in jQuery, but added "consider this article an open invitation to port this technique to your library of choice." I intended to immediately port CSS Sprites2 to Prototype and script.aculo.us, but finally got around to it this weekend.

My version of CSS Sprites2 is almost exactly the same as Dave Shea's: it requires the same HTML, the same styling and includes a similar pre-built function used to invoke it. However, my version also includes keyboard support: there's a matching focus, blur, keydown and keyup event handler for each mouse event handler.

Get CSS Sprites2 for Prototype and script.aculo.us.

The New York Web Standards Meetup Group will meet this Thursday (28 August 2008) at theMechanism at 7:00 pm.

Margaret Michele Waldman (Sovereign Sites L.L.C.) will briefly discuss Ajax and present a number of coding variations, including rolling your own, using a JavaScript library and using Xajax. The examples will demonstrate how to consume XML, HTML and JSON.

Prior to the discussion, there will be a brief period for announcements. Afterwards, there will be an optional "show and tell" session. Show off sites you’re currently working on and get design feedback and technical assistance.

28 August 2008 . 7:00 pm
theMechanism
440 9th Avenue 8th Floor
New York, NY 10001 [map]

RSVP now!

Please contact theMechanism if you'd like to present at the October or November meetup.

I know Apple is restrictive as hell about information, but I was a bit surprised to see how far the non-disclosure agreement (NDA) for the iPhone SDK goes: iPhone developers are legally banned from sharing programming tips, discussing code or asking questions of one another in forums or over e-mail!

From Webmonkey:

"FUCKING NDA" has become a mantra on Twitter. Every time a developer posts about his or her latest run-in with the metaphorical brick wall that is Apple's NDA, the capitalized expletive is sounded off. "FUCKING NDA" has become such a phenomenon, a website has sprung up at FuckingNDA.com to track the twisted tweets.

Apple's software development kit (SDK) for the iPhone is the primary set of tools for building apps for the iPhone, especially if the creations are to be included for sale in the device's App Store. The NDA, which must be agreed to before the SDK can be downloaded, prevents programmers from discussing the finer points of their code.

"There is no legal way for developers to talk about they are developing," Williams laments. "No way to post tutorials. No way to give code away. It's hard to interact with other developers and to write code without reinventing the wheel. Normally, you could post [a coding question] on Twitter and get an answer within minutes."

More info on why the iPhone NDA is no good:

Notes and links from last night's Google I/O review at the New York Web Standards Meetup Group. Thanks to everyone who made it!

Note—There's a "curated" selection of Google I/O videos on this blog tagged io2008.

PowerPoint presentation

Demos/tutorials

Advanced Gadget and UI Development Using Google's AJAX APIs. Derek Collison (Google)

The Google AJAX APIs can be used to build sophisticated Gadgets and UI controls for your website. For instance, you can by-pass complex server-side proxies and mash up feeds directly with a few lines of JavaScript using the Feed API. In this session, we'll dive into advanced uses of the raw Feed and Search APIs. We’ll also show you how to use Google's new Language API to broaden the global reach of your web applications.

Participants should be familiar with JavaScript and dynamic Web applications.

Presentation slides (PDF)

Source: YouTube

Rapid Development with Python, Django, and Google App Engine. Guido van Rossum (Google)

Learn how to create great web applications quickly on Google App Engine using the Django Web framework and the Python language. Google App Engine lets you host complete, scalable web applications written in Python with minimal fuss. This tutorial assumes basic familiarity with Python, but definitely no advanced Python knowledge; Django experience is optional. You will learn how to use the Django web framework with the datastore API provided by Google App Engine, and how to get the most mileage out of the combination. You will also see how to use Django best practices like unit testing when developing for Google App Engine.

Presentation slides (PDF)

Source: YouTube

The New York Web Standards Meetup Group will meet this Thursday (24 July 2008) at theMechanism at 7:00 pm.

Google I/O was a two day developer gathering in San Francisco, 28–28 May 2008, which covered building the next generation of Web applications with Google and open technologies.

I attended and will talk about what I learned there, specifically focusing on Gears, Google App Engine and the Google Ajax APIs. Prior to the meetup, you can read a bit about my experience at theMechanism's blog and watch some of the videos I've gathered here.

24 July 2008 . 7:00 pm
theMechanism
440 9th Avenue 8th Floor
New York, NY 10001 [map]

RSVP now!

Please contact theMechanism if you'd like to present at the September or October meetup.

State of Ajax: The Universe is Expanding. Dion Almaer (Google) and Ben Galbraith (Ajaxian.com)

The Ajax revolution is complete: sophisticated JavaScript user interfaces are nearly ubiquitous. Yet, the innovations in the Ajax community continue. In this session, Dion Almaer and Ben Galbraith, the founders of Ajaxian.com, discuss the latest Ajax developments, including multithreaded JavaScript technology-powered UIs, robust offline storage, choosing the right Ajax/JavaScript technology framework, Ajax outside of the browser and more. They use plenty of examples and a bit of live coding for dramatic effect. Come and learn how to use the latest technology to make your web applications sizzle. And, see if your heckling can throw them off balance!

Presentation slides (PDF)

Source: YouTube