I think it's going to be a mixture of both. Some things you learn by doing. You will use Google a lot to look up function names. For example, what's the name of the function to get the length of a string? You Google "Python string length" and you've got it.
In that respect you don't really need a book because online searches can help. You just need to figure out what you want to do, and Google for help with the API. No beginner's book can cover everything in the language that you might want to do so you would end up searching online anyway.
"Figuring out what you want to do", as you have no doubt discovered by now, is the real problem. Here's where books can help. You should read about theories, data structures, and techniques, to get you thinking about how to solve the problems you've got. Then it just becomes a matter of implementing the code in whatever language you've chosen.
For example, books about data structures will teach you about queues and stacks and trees and linked lists. How to store lists of things, sort them, how to search for things. Books about software design patterns will help you think about your problems in terms of things like state machines, singletons, and object pools, or help you to avoid mistakes like writing "God Objects" or using "magic numbers". A book about graphics techniques might teach you about double buffering. You might even go so far as to study machine learning techniques, like decision trees and neural networks.
To summarize: To take an algorithm or design you've already got, and turn it into Python code, you can learn by doing and Googling for API syntax. To learn how to better design programs and algorithms, read books.