Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
A fun and practical guide to learning Python with a special focus on data science, web scraping, and web applications
In Unlocking Python: A Comprehensive Guide for Beginners, veteran software engineer, educator, and author Ryan Mitchell delivers an intuitive, engaging, and practical roadmap to Python programming. The author walks you through the vocabulary, tools, foundational knowledge, and occasional pop-culture references you'll need to hone your skills with this popular programming language.
You'll learn how to install and run Python on your own machine, get up and coding with the language quickly, and best practices for programming both independently and in the workplace. You'll also find:
Perfect for tech-savvy professionals at any stage of their careers who are interested in diving into Python programming. Unlocking Python is also a must-read for readers who work in a technical role but are interested in getting more directly involved with programming, as well as non-Python programmers who want to apply their technical skill to a new language.
RYAN MITCHELL is the author of Unlocking Python (Wiley), Web Scraping with Python (O'Reilly), and multiple courses on LinkedIn Learning including Python Essential Training. She holds a master's degree in software engineering from Harvard University Extension School and has worked as principal software engineer and data scientist on the search team at the Gerson Lehrman Group for the last six years.
Part I: Programming
Chapter 1: Introduction to Programming 3
Programming as a Career 4
Myths About Programmers 4
How Computers Work 7
A Brief History of Modern Computing 12
The Unix Operating System 12
Modern Programming 13
Talking About Programming Languages 14
Problem-Solving as a Programmer 17
Chapter 2: Programming Tools 21
Shell 21
Version Control Systems 25
Authenticating with GitHub with SSH Keys 27
Integrated Development Environments 33
Web Browsers 34
Chapter 3: About Python 37
The Python Software Foundation 38
The Zen of Python 39
The Python Interpreter 40
The Python Standard Library 41
Third-Party Libraries 42
Versions and Development 43
Part II: Python
Chapter 4: Installing and Running Python 47
Installing Python 47
Windows 48
macOS 48
Linux 49
Installing and Using pip 50
Windows 51
macOS 51
Linux 51
Installing and Using Jupyter for IPython files 52
Virtual Environments 54
Anaconda 56
Chapter 5: Python Quickstart 59
Variables 59
Data Types 62
Operators 67
Arithmetic Operators 67
Operators and Assignments 69
Comparison Operators 70
Identity Operators 71
Boolean Operators 73
Membership Operators 73
Control Flow 74
If and Else 75
For 76
While 76
Functions 78
Classes 80
Everything Is an Object 82
Data Structures 82
Lists 83
Dictionaries 84
Tuples 86
Sets 86
Exercises 88
Chapter 6: Lists and Strings 91
String Operations 91
String Methods 92
List Operations 95
Slicing 97
List Comprehensions 100
Exercises 103
Chapter 7: Dictionaries, Sets, and Tuples 105
Dictionaries 105
Dictionary Comprehensions 108
Reducing to Dictionaries 110
Sets 112
Tuples 114
Exercises 116
Chapter 8: other Types of Objects 119
Other Numbers 119
Dates 124
Bytes 129
Exercises 132
Chapter 9: Iterables, Iterators, Generators, and Loops 135
Iterables and Iterators 135
Generators 137
Looping with Pass, Break, Else, and Continue 139
Assignment Expressions 143
Walrus Operators 143
Recursion 144
Exercises 148
Chapter 10: Functions 149
Positional Arguments and Keyword Arguments 149
Functions as First-Class Objects 155
Lambda Functions 158
Namespaces 160
Decorators 163
Exercises 168
Chapter 11: Classes 171
Static Methods and Attributes 173
Inheritance 175
Multiple Inheritance 178
Encapsulation 182
Polymorphism 186
Exercises 188
Chapter 12: Writing Cleaner Code 189
PEP 8 and Code Styles 189
Comments and Docstrings 190
Documentation 194
Linting 196
Formatting 199
Type Hints 200
Part III: Advanced Topics
Chapter 13: Errors and Exceptions 207
Handling Exceptions 207Else and Finally 210
Raising Exceptions 212
Custom Exceptions 214
Exception Handling Patterns 217
Exercises 223
Chapter 14: Modules and Packages 225
Modules 225
Import This 228
Packages 229
Installing Packages 235
Exercises 240
Chapter 15: Working with Files 243
Reading Files 243
Writing Files 247
Binary Files 250
Buffering Data 252
Creating and Deleting Files and Directories 254
Serializing, Deserializing, and Pickling Data 256
Exercises 259
Chapter 16: Logging 261
The Logging Module 261
Handlers 266
Formatting 269
Exercises 272
Chapter 17: Threads and Processes 275
How Threads and Processes Work 275
Threading Module 276
Locking 280
Queues 283
Multiprocessing Module 285
Exercises 292
Chapter 18: Databases 293
Installing and Using SQLite 294
Installing SQLite 294
Using SQLite 296
Query Language Syntax 297
Using SQLite with Python 300
Object Relational Mapping 303
Exercises 306
Chapter 19: Unit Testing 307
The Unit Testing Framework 309
Setting Up and Tearing Down 312
Mocking Methods 314
Mocking with Side Effects 318
Part IV: Python Frameworks
Chapter 20: Rest Apis and Flask 323
HTTP and APIs 323
Getting Started with Flask Applications 327
APIs in Flask 330
Databases 333
Authentication 336
Sessions 338
Templates 342
Chapter 21: Django 345
Installing Django and Starting Django 346
Databases and Migrations 351
Django Admin Interface 353
Models 355
More Views and Templates 358
More Resources 361
Chapter 22: Web Scraping and Scrapy 363
Installing and Using Scrapy 364
Parsing HTML 366
Items 371
Crawling with Scrapy 372
Item Pipelines 376
Chapter 23: Data Analysis with Numpy and Pandas 379
NumPy Arrays 380
Pandas DataFrames 383
Cleaning 387
Filtering and Querying 391
Grouping and Aggregating 393
Chapter 24: Machine Learning with Matplotlib And Scikit-learn 397
Types of Machine Learning Models 398
Exploratory Analysis with Matplotlib 400
Building Supervised Models with Scikit-Learn 409
Evaluating Classification Models with Scikit-Learn 415
Index 421
The computer programmer is a creator of universes for which he alone is the lawgiver. No playwright, no stage director, no emperor, however powerful, has ever exercised such absolute authority to arrange a stage or field of battle and to command such unswervingly dutiful actors or troops.
- JOSEPH WEIZENBAUM
The programming book has a curious place in the modern world. With Python documentation, tutorials, and entire courses available online, what is the purpose of long-form text on the subject?
Similarly, what is the purpose of, say, historian John Keegan's book The First World War when a straightforward timeline of battles is readily available? This question is, obviously (at least, I hope), rhetorical. Books convey the author's point of view, insights, colorful commentary, and perhaps even add a little entertainment to the mix. They present facts, expand on those facts, and bring them to life.
For most people, the concept of "bringing history to life" probably makes more visceral and immediate sense than the concept of "bringing programming to life." This is unfortunate.
The goal of this book is to teach you to write Python programs, yes, and also to discuss the history, culture, and context of Python, the machines that run it, and the people who write it. The first step to understanding a programming language isn't simply copying that first line of code and hitting the Go button-it's learning what the computer is doing while that first line of code is running.
Whatever your motivations for learning Python, I hope this text can inspire in you the same enthusiasm I have for Python, and programming in general. In some small way, perhaps it can bring it to life.
"If you could be anyone in King Arthur's court, who would you be?" was the question posed to me one weekend afternoon in the kitchen of my childhood home by my uncle, a software engineer visiting from Massachusetts.
As a teenager, my knowledge of King Arthur was mainly limited to the film Monty Python and the Holy Grail, so even thinking of suitable answers was difficult. There was Lancelot, Galahad, and all the rest of the knights, but none of them seemed especially worth becoming. "King Arthur" himself would have been a fun way to respond, but surely, there must be a more interesting character. What about the Lady of the Lake-the kingmaker herself?
Of course, in some versions, such as the 1963 Disney classic The Sword in the Stone, Arthur becomes king, not by women in ponds distributing swords, but by pulling Excalibur out of a stone. I thought about that movie, too.
And, certain that my answer was cheating somehow, I finally gave my uncle the snarky response: "Merlin."
This, of course, is the correct answer. Years later, my uncle said that it was because of this answer that he knew my future profession as a programmer was inevitable.
The association between programming and wizardry is a long one. And the association between programmers and snarky responses is even longer.
Programmers shape the world we view through our screens and create new realities seemingly out of thin air. They realize that the boundaries of the virtual world are artificially constructed. They either implement the rules passed down by kings or subvert them as they choose. They perform feats by mastering the arcane languages.
The power of King Arthur depends on external factors: his fame, wealth, political clout, and societal recognition of his authority. The power that Merlin has is intrinsic.
Of course, even if my response had been "King Arthur," I still would have become a programmer. Software engineers giving single-question personality tests to teenagers is no basis for career determination, just like yanking a sword out of a rock doesn't make you a king.
Let's be honest: Many aspiring programmers get interested in the field tempted by big paychecks, job security, great benefits, and favorable working conditions. These things are all nice, to be sure. But getting hundreds of thousands of dollars a year from a big-name company is far more challenging than most programming bootcamps would have you believe. Also very common (but less lauded in the media) are entry-level programmers working long hours for small companies, nonprofits, and start-ups whose funding allows them a runway measured in months.
As a programmer you will experience both good times and bad times. Times when you are working from your couch on very easy and enjoyable projects for lots of money. And times when you are, perhaps volunteering (or working for so little in return that it's essentially volunteering), on stressful projects in an office with a long commute and a strict dress code.
So, what really differentiates programmers and nonprogrammers? The people who stick it out and have long, happy careers, and the ones who give up in frustration? I want to address a few industry misconceptions about what's "required" to be a programmer:
For the vast majority of you learning to program, there are going to be certain problems you're not going to understand right away, certain concepts you're just not going to get. And these have nothing to do with some fundamental deficiency in your brain.
Programming is a marathon, not a sprint. Determination and consistency with always be more valuable in programing than genius.
There is also the complicating factor that it can be difficult to estimate how much time is required to add a feature or fix a bug. If you are working for a small and/or mismanaged company, you may occasionally find yourself in a situation where a feature is required to be added by a certain deadline; complications arise, ballooning the hours required to add it; and you are the only one who can rescue the project.
But this is not a common situation, and if you find yourself doing this more than once or perhaps twice a year, consider finding new employment. In general, working as a programmer is the same as working anywhere else; in a well-managed company with good work-life balance, the hours are about the same as they are for any other profession.
Technically, the above is all true. However, it's also a very disingenuous view of the realities of modern programming. For starters, we have software that finds and highlights errors as we write the code (for more information, see Chapter 12, "Writing Cleaner Code"). It's somewhat difficult to make a simple syntax error or to forget a character-the code must still be syntactically valid in order for it to run at all. At the very least, you should probably make sure it runs-not that it produces the correct output but merely runs at all-before it goes anywhere important.
Programs are usually run in various testing environments over many scenarios. New features get multiple stages of testing and review before they go to production. And that's just for the code that doesn't have any lives depending on it!
I know many meticulous, detail-oriented programmers. But to be honest, I don't know anyone who would describe me similarly.
The great thing about computers is that, when something does go wrong, it will tell you what went wrong and where (at least to some extent). You see an error message, a stack trace, or at least an output that's different than what you were expecting. Nothing blows up, nobody dies, you're just sitting there at your computer with a puzzle to solve and something to fix.
Can extreme conscientiousness be an asset in programming? Absolutely! Is it required? Not at all.
However, there is one intersection between programming and...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.