Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.
| # Python logger in AWS Lambda has a preset format. To change the format of the logging statement, | |
| # remove the logging handler & add a new handler with the required format | |
| import logging | |
| import sys | |
| def setup_logging(): | |
| logger = logging.getLogger() | |
| for h in logger.handlers: | |
| logger.removeHandler(h) |
by Bjørn Friese
Beautiful is better than ugly. Explicit is better than implicit.
I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.
Here is the raw output from examining the Python LambdaContext context object in a AWS Lambda function when called from a CloudFormation stack. More information on the context object can be found here : http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html
<__main__.LambdaContext object at 0x7fd706780710>
| /** | |
| * The onOpen function runs automatically when the Google Docs document is | |
| * opened. Use it to add custom menus to Google Docs that allow the user to run | |
| * custom scripts. For more information, please consult the following two | |
| * resources. | |
| * | |
| * Extending Google Docs developer guide: | |
| * https://developers.google.com/apps-script/guides/docs | |
| * | |
| * Document service reference documentation: |
| ''' quick example showing how to attach a pdf to multipart messages | |
| and then send them from SES via boto | |
| ''' | |
| from email.mime.text import MIMEText | |
| from email.mime.application import MIMEApplication | |
| from email.mime.multipart import MIMEMultipart | |
| import boto |