a blog by Marius Gedminas

Posts tagged Python

Sending Unicode emails in Python

Sending a properly encoded email that contains non-ASCII characters is not as trivial as it should be. Here's more or less what I want: # U+263A and U+263B are smiley faces (☺ and ☻) sender = u'Sender \u263A <sender@example.com>' recipient = u'Recipient \u263B <recipient@example.com>' subject = u'Smile! \u263A' body = u'Smile!\n\u263B' send_email(sender, recipient, subject, body) The hard part is getting all the unicode strings to be properly encoded in the email.

Using the SchoolTool test runner to run Zope 3 tests

The SchoolTool test runner has a couple of features that the Zope 3 test runner does not have. When an error occurs while rendering a Zope Page Template, the SchoolTool test runner can show you the location in the template as well as the relevant TALES expression in the traceback. You can instruct the SchoolTool test runner to limit recursive directory tree walks to a subdirectory in your source three -- this shaves off whooping 6 seconds when you want to test a single Zope 3 package.