Books, Things, and more Books

code2

So you’ve decided to give programming a go, or maybe try out a new language, or, maybe you are a seasoned developer who is going  wrip this post and my feelings apart.  In any case,  let’s talk about Python! 

While many wonderful things can be found across the internet, finding something useful can be a challenge.  While sites like Codecademy, Code School, Udacity, and a number of other online resources provide a more modern means of learning how to program (often at no or little cost), throwing in more traditional methods on top of that can be extremely beneficial.

While the manner in which you learn something new is entirely up to you, I’ve found in many cases that the process itself is accomplished through multiple methods.  For me, and many others, reading books/guides, practice exercises (from books or websites), and larger projects will provide the most complete coverage.  Over the next few weeks, I will share resources and practices that I’ve found helpful.  While most of my focus will be Python related, the future section on practice exercises and projects can be applied to any language.  Today, I cover beginner-to-intermediate text-based resources.

Comprehensive Texts

The books in this section are suited for people with no programming experience, or those looking to just learn the Python syntax.  While each book contains valuable information for intermediate level programmers as well, know that the initial chapters of all my recommendations cover basic python/programming concepts.  Noteworthy and additional topics of interest are noted for each book.

Title:   Python Crash Course (Eric Matthes)
Links: Homepage | Sample Chapter
Cost:   Paid – Ebook and Hardcopies available

Additional Topics: Unit Tests, Django, Git, Data Science, Pygame, Web Scraping
Considerations:  String formatting not covered.


Python Crash Course (PCC) covers everything from basic data types all the way to object oriented programming.  While reading about a new concept is great, putting it into practice is often essential to internalizing that subject.  While practice exercises in general are great, PCC’s exercises are included throughout each chapter, as opposed to just at the end of the chapter. While these exercises are more compact than normal end-chapter problems, they do force you put the concepts covered into practice more frequently.  The problem sets also do a great job of dividing the various concepts presented in each chapter into manageable subsections.

The book is divided into two parts; part 1 deals with fundamental programming concepts while part 2 covers three large projects: building a game using Pygame, utilizing data science tools, and building a website (with user login and forum posting) using Django. These projects put into practice all the skills covered in the first half of the book, and each step is guided by the author.  The smaller in-chapter exercises found in part 1 of the book are still present in part 2; although the author guides each step of the project, multiple opportunities are given to apply these concepts without direction.

While the book is not free, it can be found for around $25, which is extremely reasonable.  The large projects offered in the second half of the book more than make up for the cost.

 

Title:   Automate the Boring Stuff with Python (Al Sweigart)
Links: Homepage | Sample Chapter
Cost:   Free online, paid hardcopy/ebook available

Additional Topics:  Regular Expressions, Debugging, Web Scraping, Task Automation
Considerations: Object oriented programming and string formatting not covered.


Automate the Boring Stuff with Python (AtBS) is one of the most recommended beginner books for Python.  Every chapter focuses on examples and exercises aimed at real world application.  AtBS’s biggest asset is how it developes a new programmers ability to apply the concepts they learn to relatable environments (everything from organizing files to automating keyboard/mouse actions).  While many learning resources already do this, AtBS provides much more focus on this practice than what is standard.

Although early chapters focus fundamental Python/programming concepts, as the title of the book suggests, there is a strong focus on task automation.  The author is a big fan of it, and he actually wrote many of the modules used throughout various chapters.  AtBS is an example of utilizing a variety of resources when learning a new subject.  Although it will core Python concepts, object oriented programming is not covered.  The online version is entirely free and you will learn about areas of Python not typically covered in other texts.

In terms of practical exercises, early chapters include various problem sets that cover fundamental concepts of the chapter, while later chapters include more involved problems, or large projects.  While not as frequent as PCC’s in-chapter exercises, important concepts found throughout each section are still put into practice.

 

Title:   Python 101 (Michael Driscoll)
Links: Homepage | Sample Chapter
Cost:   Free online, option to donate to author available

Additional Topics: Decorators, Building Executables & Packages, Virtualenv, many more
Considerations: Not as many practice exercises as PCC or AtBS


In addition to covering basic Python concepts, Python 101 (101) also details a number of extended library modules and packages, and a variety of other topics across 40+ chapters.  Although the chapters are numerous in number, they are concise and well organized.   The value of 101 is that it will introduce you to a wide array of modules and practices not typically covered by other texts.  While this may sound like a pocket reference, it’s not; each chapter contains numerous examples and explanations of each step.

Because of the number of topics covered, additional concepts worth mentioning are: string formatting, the SQLAlchemy and sqlite modules, the threading and subprocess modules, and sections on debugging and testing.  If you want a list of all topics covered, you can find the table of contents here.  After chapter 11 (Object Oriented Programming), the rest of the book can be viewed in almost any order.  The only downside of 101 is that  few exercises are explicitly given, however, the example problems themselves give a strong indication of what specific concepts can be used for.
 

A Note on String Formatting


If you are a beginner, or if you haven’t heard of string formatting before (the .format() method in python), this section applies to you.  If this is your first time reading about programming, for reference, strings are just sequences of characters.  This sentence is a string, for example.

I started with both Python Crash Course and Automate the Boring Stuff, and while they are great, string concatenation is the only method taught as a means of formatting text that will be displayed on screen.  While PCC mentions an alternative method, it’s mentioned briefly on two pages in the second half of the book. For reference, when I’m talking about about string concatenation, I mean this:

print('Hello' + 'World!') #Displays: Hello World!

or this, which  accomplishes the same thing

print('Hello', 'World!') #Displays: Hello World!

In Python, you can use the ‘+’,  sign,  or you  can separate characters/variables with a comma to combine words/ variables together.  Sometimes, it’s needed, but for printing some kind of output to the screen, string formatting is a better (and faster) method.  For example, If we had multiple names we wanted to print, and those names were stored in variables, using the above method would require this:

first_guest = 'Jenny'
second_guest = 'Bob'
third_guest = 'Lisa'

# Jenny, Bob, and Lisa are coming to the party.
print(first_guest + ', ' + second_guest + ', and ' + third_guest + ' are coming to the party.')

This makes the code hard to read and error prone, all of which is exacerbated as more words or variables are added .  An alternate method would be using string formatting via the .format() method, like so:

first_guest = 'Jenny'
second_guest = 'Bob'
third_guest = 'Lisa'

# Jenny, Bob, and Lisa are coming to the party.
print('{}, {}, and {} are coming to the party.'.format(first_guest, second_guest, third_guest))

The extremely over-simplified difference is that curly brackets ‘{}’ are placeholders for variable or expression names, and the .format() method contains the variable/expressions (separated by commas) in the order they are to appear in the sentence.  Much more can be accomplished with .format() than can be covered here; more information, along with great examples and explanations can be found in this comprehensive guide.

The above link also provides examples of the old method of string formatting in python (which essentially behaves like C’s printf() function).  There is an even newer method of string formatting, literal string interpolation (or f’strings’), that provides an additional method of string formatting.  It’s only supported in Python 3.5+, and although there aren’t as many guides on it, it’s worth looking into at some point.

String concatenation isn’t inherently bad when used in the right cases; however, when printing text to the screen, typically, some type of string formatting will save time and make code more readable.  In the defense of both PCC and AtBS, string concatenation is an easier way of teaching how  words, characters, and variables can be combined.  The notion of ‘adding’ parts of a string together is much more intuitive.  By all means, if you are just starting out, and this is a confusing concept, go with whatever makes sense first, you can always come back later; this is by no means a priority.

 

Final Thoughts


There is a difference between asking “what book should I start with” and “what book should I use” in regards to learning something new.  In terms of programming, there is rarely a case where a single resource will give all the practice and information necessary to fully harness the features of a language.  While some texts are extremely well written and thorough, utilizing only a single resource prevents one from getting the insight of a different individual solving problems their own way.

By no means am I suggesting that read all these books need to be read to become good at Python, or programming in general; you don’t.  Reading these books has shown me the value in learning to solve a problem in multiple ways, and they have provided unique contexts I would have never experienced otherwise.  There are dozens, if not hundreds of books on Python alone, and this small list doesn’t represent the best out of that set; in addition to being extremely helpful early on, they sparked my interest, conveyed concepts clearly, and are still useful today.

With that in mind, if you have any resources that you found particularly useful, feel free to share; additional perspectives for myself, and for anyone who comes across them is always nice.

Now, on the topic of awkward and forced transitions, that’s all I got. Tune in next time for some intermediate-to-advanced level resources, and texts that didn’t really fit in the context of this guide!

3 thoughts on “Books, Things, and more Books

  1. I am currently working my way through PCC, and it’s a great book! I just finished chapter 5 today, and I’m really excited to keep going! Thanks for the additional recommendations! 🙂

    I have also seen others recommend “Learn Python the Hard Way,” but that book doesn’t use Python 3 (so I’m not sure if I should add it to my list or not). Thoughts?

    Liked by 1 person

    • Hi Dina, no problem! Chapter 6 in PCC, dictionaries, is great! Zed Shaw, the author of Learn Python the hard Way, actually recently released a new version called Learn Python 3 the Hard Way, a free version is available through his website.

      The book itself is straightforward, but his teaching style is somewhat unique; some people like his method, some don’t. While it was never for me personally, I know it’s been a useful resource for many.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s