Saturday, July 30, 2011

Dive Into Python 3

Mark Pilgrim's Dive Into Python 3 is a hands-on guide to Python 3 (the latest version of the Python language) and its differences from Python 2. As in the original book, Dive Into Python, each chapter starts with a real, complete code sample, proceeds to pick it apart and explain the pieces, and then puts it all back together in a summary at the end.

Dive Into Python 3 is a Python book for experienced programmers. Whether you're an experienced programmer looking to get into Python 3 or grizzled Python veteran who remembers the days when you had to import the string module, Dive Into Python 3 is your 'desert island' Python 3 book. If you've never programmed before, Python 3 is an excellent language to learn modern programming techniques. But this book should not be your starting point.

Get "How to Think Like a Computer Scientist: Learning with Python" by Allen Downey, Jeffrey Elkner, Chris Meyers and learn the basics. Then dive into this book. Dive Into PYTHON 3 was written by Mark Pilgram, and this edition is distributed under the terms of the Creative Commons Attribution Share-Alike License 3.0. * Money raised from the sale of this book supports the development of free software and documentation.

About the Author: By day, Mark Pilgrim is a developer advocate for open source and open standards. By night, he is a husband and father who lives in North Carolina with his wife, his two sons, and his big slobbery dog. He spends his copious free time sunbathing, skydiving, and making up autobiographical information.

Saturday, July 16, 2011

Syma S107/S107G R/C Helicopter - Yellow

I don't know about you, but my little boy likes one of these awesome toys. We got him a nice Syma S107/S107G R/C Helicopter - Yellow. The last time we bought him something of that sort, it ended up in the bin within days of buying it.

However, this particular one seems to last much longer. It does feel like the best of the Syma toys on the market right now for those with children especially boys. If you have a child and would like to treat him to a nice toy, I would recommend you get them this top of the range Syma S107/S107G R/C Helicopter - Yellow

Sunday, July 10, 2011

Using Sep in Python

If you have been working with the latest Python 3 to a degree, chances are that you will have come across some very tricky and trivial piece of code that would run easily on Python 2.* but not on Python 3. This is one of the huge number of changes that was introduced in this Python 3 version, and sometimes you need to go back to the documentation to really work out how to use them. Below is a quick example on how you could use the new Sep.

Here's simple example of that in action:

place = "London"
print("Hello from ", place, '!');

If you run that, you will get
Hello from London !

The new print() method by default inserts a space at the end of its arguments. To avoid that space you will need to explicitly specify the 'sep' keyword.

print ("Hello from ", place, "!", sep="") # Note the explicit " " after "Hello"
Another goodie is that you can easily get useful information about modules, classes, keywords, and functions, e. g.

>>> help(print)

I will find time over the weekend to update this post and add a lot more examples here. I see lots of people searching for how to use sep - and it's important to have various examples that demonstrate how to effectively use it.

However, if you have a much bigger text than the one shown above, you will need to concatenate them before printing. Here's an example of how you might also want to use it:
output = "".join(["Hello ",name,"!"])  # thats an empty string to start 

As I have always said, use the >>> prompt to experiment to find which works best for you. It is one of the most powerful methods to learn how to use Python's huge collection of modules.
Related Posts with Thumbnails