Wednesday, July 6, 2011

Get Better at Python - Tips and Tricks

Interested in learning some of the lesser known features of Python? Check out, "The Hacker's Guide for Python on Ubuntu" on http://baybo.it/shop/p/502

Excerpt:
The Hacker's Guide to Python on Ubuntu. Anyone can go online and read the Python API. This guide is not intended to teach you Python but rather to share the lesser known secrets about the Python programming language, help you better master the language, and identify the strengths and weaknesses of the language. Learn elegant solutions to common python problems, all in one convenient place and with clear explanations.
 
Table of Contents:
1. Introduction
    a. Target Audience
    b. Definitions and Overview
    c. Tools and Setup
2. Python Built-ins
    a. Uncommon Operators
    b. Random generators
    c. dir(), __doc__, and other helpful builtins
3. “Strings”
    a. String Formatting Fun with Dictionaries
4. {Sets} and {“Python” : “Dictionaries”}
5. [“Python”, “Lists”]
6. Web Frameworks and Webpy
    a. What is a web framework?
    b. Web framework comparison
    c. Webpy
7. Extras, Fun, and Easter Eggs
    a. Fun hackery, jokes, and Easter eggs
    b. Supplemental Resources
8. Coming Soon: (Sample)
    a. Code for Writing a 2D Game - Tutorial In progress (view blog)
    b. Good Programming (and helpful/good practices)
    c. Decorators, and more
9. Supplemental Resources and Modules for Any Occasion

Selected Examples:
# Using stepping by fives
>>> "Pass your text here oh funnies!"[::5]
‘Python!’


#Generate a List Containing Letters of the Alphabet
>>> import string
>>> list(string.uppercase)
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

#Flooring Operator
>>> 3.2 // 1.3
2.0


Feel free to direct all suggestions, questions, or requests to mek@babolabs.com

Thanks for your interest,
- Mek