Fluent Python: clear, concise, and effective programming
Gespeichert in:
1. Verfasser: | |
---|---|
Format: | Buch |
Sprache: | English |
Ausgabe: | First edition |
Schlagworte: | |
Online-Zugang: | Inhaltsverzeichnis |
Beschreibung: | Hier auch später erschienene, unveränderte Nachdrucke |
Beschreibung: | xxiv, 765 Seiten Illustrationen |
ISBN: | 9781491946008 1491946008 |
Internformat
MARC
LEADER | 00000nam a2200000 c 4500 | ||
---|---|---|---|
001 | BV042940164 | ||
003 | DE-604 | ||
005 | 20211018 | ||
007 | t | ||
008 | 151021s2015 a||| |||| 00||| eng d | ||
020 | |a 9781491946008 |c kart. : ca. EUR 53.70 (DE), $ 59.99 (US), $ 79.99 (CAN) |9 978-1-491-94600-8 | ||
020 | |a 1491946008 |9 1-491-94600-8 | ||
035 | |a (OCoLC)931313589 | ||
035 | |a (DE-599)BVBBV042940164 | ||
040 | |a DE-604 |b ger |e rakwb | ||
041 | 0 | |a eng | |
049 | |a DE-11 |a DE-473 |a DE-83 |a DE-384 |a DE-Aug4 |a DE-525 |a DE-523 |a DE-29T |a DE-20 |a DE-706 |a DE-521 |a DE-862 |a DE-703 |a DE-860 | ||
084 | |a ST 250 |0 (DE-625)143626: |2 rvk | ||
100 | 1 | |a Ramalho, Luciano |0 (DE-588)1077177372 |4 aut | |
245 | 1 | 0 | |a Fluent Python |b clear, concise, and effective programming |c Luciano Ramalho |
250 | |a First edition | ||
264 | 0 | |a Beijing ; Boston ; Farnham ; Sebastopol, CA ; Tokyo |b O'Reilly |c 2015 | |
300 | |a xxiv, 765 Seiten |b Illustrationen | ||
336 | |b txt |2 rdacontent | ||
337 | |b n |2 rdamedia | ||
338 | |b nc |2 rdacarrier | ||
500 | |a Hier auch später erschienene, unveränderte Nachdrucke | ||
650 | 0 | 7 | |a Python |g Programmiersprache |0 (DE-588)4434275-5 |2 gnd |9 rswk-swf |
689 | 0 | 0 | |a Python |g Programmiersprache |0 (DE-588)4434275-5 |D s |
689 | 0 | |5 DE-604 | |
776 | 0 | 8 | |i Erscheint auch als |n Online-Ausgabe |w (DE-604)BV043019674 |
856 | 4 | 2 | |m HBZ Datenaustausch |q application/pdf |u http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=028366671&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |3 Inhaltsverzeichnis |
999 | |a oai:aleph.bib-bvb.de:BVB01-028366671 |
Datensatz im Suchindex
DE-BY-862_location | 2000 |
---|---|
DE-BY-FWS_call_number | 2000/ST 250 P99 R165 |
DE-BY-FWS_katkey | 740914 |
DE-BY-FWS_media_number | 083000523109 |
_version_ | 1806176673117241344 |
adam_text | Titel: Fluent Python
Autor: Ramalho, Luciano
Jahr: 2015
Table of Contents
Preface.......................................................................xv
Part I. Prologue
1. The Python Data Model..................................................... 3
A Pythonic Card Deck 4
How Special Methods Are Used 8
Emulating Numeric Types 9
String Representation 11
Arithmetic Operators 12
Boolean Value of a Custom Type 12
Overview of Special Methods 13
Why len Is Not a Method 14
Chapter Summary 15
Further Reading 15
Part II. Data Structures
2. An Array of Sequences..................................................... 21
Overview of Built-in Sequences 22
List Comprehensions and Generator Expressions 23
List Comprehensions and Readability 23
Listcomps Versus map and filter 25
Cartesian Products 26
Generator Expressions 27
Tuples Are Not Just Immutable Lists 28
Tuples as Records 29
Tuple Unpacking 30
Nested Tuple Unpacking 32
Named Tuples 33
Tuples as Immutable Lists 34
Slicing 35
Why Slices and Range Exclude the Last Item 36
Slice Objects 35
Multidimensional Slicing and Ellipsis 37
Assigning to Slices 33
Using + and * with Sequences 39
Building Lists of Lists 39
Augmented Assignment with Sequences 41
A += Assignment Puzzler 42
list.sort and the sorted Built-in Function 45
Managing Ordered Sequences with bisect 47
Searching with bisect 47
Inserting with bisect.insort 50
When a List Is Not the Answer 51
Arrays 51
Memory Views 54
NumPy and SciPy 55
Deques and Other Queues 58
Chapter Summary 61
Further Reading 62
Dictionaries and Sets...................................................... 67
Generic Mapping Types 68
diet Comprehensions 70
Overview of Common Mapping Methods 71
Handling Missing Keys with setdefault 72
Mappings with Flexible Key Lookup 74
defaultdict: Another Take on Missing Keys 75
The__missing__Method 76
Variations of diet 79
Subclassing UserDict 80
Immutable Mappings 82
Set Theory 83
set Literals 85
Set Comprehensions 86
Set Operations 87
diet and set Under the Hood 90
Table of Contents
A Performance Experiment 90
Hash Tables in Dictionaries 92
Practical Consequences of How diet Works 95
How Sets Work—Practical Consequences 98
Chapter Summary 98
Further Reading 99
4. Text versus Bytes.........................................................101
Character Issues 102
Byte Essentials 103
Structs and Memory Views 106
Basic Encoders/Decoders 107
Understanding Encode/Decode Problems 109
Coping with UnicodeEncodeError 109
Coping with UnicodeDecodeError 110
SyntaxError When Loading Modules with Unexpected Encoding 112
How to Discover the Encoding of a Byte Sequence 113
BOM: A Useful Gremlin 114
Handling Text Files 115
Encoding Defaults: A Madhouse 118
Normalizing Unicode for Saner Comparisons 121
Case Folding 124
Utility Functions for Normalized Text Matching 125
Extreme Normalization : Taking Out Diacritics 126
Sorting Unicode Text 129
Sorting with the Unicode Collation Algorithm 131
The Unicode Database 132
Dual-Mode str and bytes APIs 134
str Versus bytes in Regular Expressions 134
str Versus bytes on os Functions 135
Chapter Summary 138
Further Reading 139
Part III. Functions as Objects
5. First-Class Functions...................................................... 145
Treating a Function Like an Object 146
Higher-Order Functions 147
Modern Replacements for map, filter, and reduce 148
Anonymous Functions 150
The Seven Flavors of Callable Objects 151
Table of Contents I vii
User-Defined Callable Types 152
Function Introspection 153
From Positional to Keyword-Only Parameters 155
Retrieving Information About Parameters 156
Function Annotations 161
Packages for Functional Programming 163
The operator Module 163
Freezing Arguments with functools.partial 167
Chapter Summary 169
Further Reading 169
6. Design Patterns with First-Class Functions................................... 173
Case Study: Refactoring Strategy 174
Classic Strategy 174
Function-Oriented Strategy 178
Choosing the Best Strategy: Simple Approach 181
Finding Strategies in a Module 182
Command 184
Chapter Summary 185
Further Reading 186
7. Function Decorators and Closures...........................................189
Decorators 101 190
When Python Executes Decorators 191
Decorator-Enhanced Strategy Pattern 193
Variable Scope Rules 195
Closures 198
The nonlocal Declaration 201
Implementing a Simple Decorator 203
How It Works 204
Decorators in the Standard Library 206
Memoization with functools.lru_cache 206
Generic Functions with Single Dispatch 208
Stacked Decorators 212
Parameterized Decorators 212
A Parameterized Registration Decorator 213
The Parameterized Clock Decorator 215
Chapter Summary 218
Further Reading 218
viii I Table of Contents
Part IV. Object-Oriented Idioms
8. Object References, Mutability, and Recycling.................................225
Variables Are Not Boxes 226
Identity, Equality, and Aliases 227
Choosing Between == and is 229
The Relative Immutability of Tuples 230
Copies Are Shallow by Default 231
Deep and Shallow Copies of Arbitrary Objects 234
Function Parameters as References 235
Mutable Types as Parameter Defaults: Bad Idea 236
Defensive Programming with Mutable Parameters 239
del and Garbage Collection 241
Weak References 242
The WeakValueDictionary Skit 244
Limitations of Weak References 246
Tricks Python Plays with Immutables 247
Chapter Summary 249
Further Reading 250
9. A Pythonic Object........................................................ 255
Object Representations 256
Vector Class Redux 256
An Alternative Constructor 260
classmethod Versus staticmethod 260
Formatted Displays 262
A Hashable Vector2d 266
Private and Protected Attributes in Python 272
Saving Space with the __slots__Class Attribute 274
The Problems with__slots__ 276
Overriding Class Attributes 277
Chapter Summary 279
Further Reading 281
10. Sequence Hacking, Hashing, and Slicing..................................... 285
Vector: A User-Defined Sequence Type 286
Vector Take #1: Vector2d Compatible 286
Protocols and Duck Typing 289
Vector Take #2: A Sliceable Sequence 290
How Slicing Works 291
A Slice-Aware__getitem__ 293
Vector Take #3: Dynamic Attribute Access 295
Table of Contents | ix
Vector Take #4: Hashing and a Faster == 299
Vector Take #5: Formatting 305
Chapter Summary 312
Further Reading 313
11. Interfaces: From Protocols to ABCs..........................................319
Interfaces and Protocols in Python Culture 320
Python Digs Sequences 322
Monkey-Patching to Implement a Protocol at Runtime 324
Alex Martelli s Waterfowl 326
Subclassing an ABC 331
ABCs in the Standard Library 333
ABCs in collections.abc 333
The Numbers Tower of ABCs 335
Defining and Using an ABC 336
ABC Syntax Details 340
Subclassing the Tombola ABC 341
A Virtual Subclass of Tombola 344
How the Tombola Subclasses Were Tested 347
Usage of register in Practice 350
Geese Can Behave as Ducks 351
Chapter Summary 352
Further Reading 355
12. Inheritance: For Good or For Worse......................................... 361
Subclassing Built-in Types Is Tricky 362
Multiple Inheritance and Method Resolution Order 365
Multiple Inheritance in the Real World 371
Coping with Multiple Inheritance 373
1. Distinguish Interface Inheritance from Implementation Inheritance 374
2. Make Interfaces Explicit with ABCs 374
3. Use Mixins for Code Reuse 374
4. Make Mixins Explicit by Naming 374
5. An ABC May Also Be a Mixin; The Reverse Is Not True 374
6. Don t Subclass from More Than One Concrete Class 375
7. Provide Aggregate Classes to Users 375
8. Favor Object Composition Over Class Inheritance. 376
Tkinter: The Good, the Bad, and the Ugly 376
A Modern Example: Mixins in Django Generic Views 377
Chapter Summary 3 81
Further Reading 382
Table of Contents
13. Operator Overloading: Doing It Right........................................385
Operator Overloading 101 386
Unary Operators 386
Overloading + for Vector Addition 389
Overloading * for Scalar Multiplication 394
Rich Comparison Operators 399
Augmented Assignment Operators 403
Chapter Summary 408
Further Reading 409
PartV. Control Flow
14. Iterables, terators, and Generators.........................................415
Sentence Take # 1: A Sequence of Words 416
Why Sequences Are Iterable: The iter Function 418
Iterables Versus Iterators 420
Sentence Take #2: A Classic Iterator 424
Making Sentence an Iterator: Bad Idea 425
Sentence Take #3: A Generator Function 426
How a Generator Function Works 428
Sentence Take #4: A Lazy Implementation 431
Sentence Take #5: A Generator Expression 432
Generator Expressions: When to Use Them 434
Another Example: Arithmetic Progression Generator 435
Arithmetic Progression with itertools 438
Generator Functions in the Standard Library 439
New Syntax in Python 3.3: yield from 449
Iterable Reducing Functions 450
A Closer Look at the iter Function 452
Case Study: Generators in a Database Conversion Utility 453
Generators as Coroutines 455
Chapter Summary 455
Further Reading 456
15. Context Managers and else Blocks.......................................... 463
Do This, Then That: else Blocks Beyond if 464
Context Managers and with Blocks 466
The contextlib Utilities 470
Using @contextmanager 471
Chapter Summary 476
Further Reading 476
Table of Contents
16. Coroutines.............................................................. 479
How Coroutines Evolved from Generators 480
Basic Behavior of a Generator Used as a Coroutine 481
Example: Coroutine to Compute a Running Average 484
Decorators for Coroutine Priming 486
Coroutine Termination and Exception Handling 488
Returning a Value from a Coroutine 491
Using yield from 494
The Meaning of yield from 500
Use Case: Coroutines for Discrete Event Simulation 506
About Discrete Event Simulations 507
The Taxi Fleet Simulation 508
Chapter Summary 516
F urther Reading 518
17. Concurrency with Futures................................................. 523
Example: Web Downloads in Three Styles 523
A Sequential Download Script 525
Downloading with concurrent.futures 528
Where Are the Futures? 529
Blocking I/O and the GIL 533
Launching Processes with concurrentfutures 534
Experimenting with Executor.map 536
Downloads with Progress Display and Error Handling 539
Error Handling in the flags2 Examples 544
Using futures.as_completed 547
Threading and Multiprocessing Alternatives 550
Chapter Summary 550
Further Reading 551
18. Concurrency with asyncio..................................................557
Thread Versus Coroutine: A Comparison 559
asyncio.Future: Nonblocking by Design 566
Yielding from Futures, Tasks, and Coroutines 567
Downloading with asyncio and aiohttp 568
Running Circles Around Blocking Calls 573
Enhancing the asyncio downloader Script 575
Using asyncio.as_completed 576
Using an Executor to Avoid Blocking the Event Loop 582
From Callbacks to Futures and Coroutines 583
Doing Multiple Requests for Each Download 586
Writing asyncio Servers 589
xii I Table of Contents
An asyncio TCP Server 590
An aiohttp Web Server 595
Smarter Clients for Better Concurrency 598
Chapter Summary 599
Further Reading 601
Part VI. Metaprogramming
19. Dynamic Attributes and Properties......................................... 607
Data Wrangling with Dynamic Attributes 608
Exploring JSON-Like Data with Dynamic Attributes 610
The Invalid Attribute Name Problem 614
Flexible Object Creation with__new__ 615
Restructuring the OSCON Feed with shelve 617
Linked Record Retrieval with Properties 621
Using a Property for Attribute Validation 628
Lineltem Take #1: Class for an Item in an Order 628
Lineltem Take #2: A Validating Property 629
A Proper Look at Properties 630
Properties Override Instance Attributes 632
Property Documentation 634
Coding a Property Factory 636
Handling Attribute Deletion 639
Essential Attributes and Functions for Attribute Handling 640
Special Attributes that Affect Attrib ute Handling 640
Built-in Functions for Attribute Handling 641
Special Methods for Attribute Handling 642
Chapter Summary 643
Further Reading 644
20. Attribute Descriptors..................................................... 649
Descriptor Example: Attribute Validation 650
Lineltem Take #3: A Simple Descriptor 650
Lineltem Take #4: Automatic Storage Attribute Names 655
Lineltem Take #5: A New Descriptor Type 661
Overriding Versus Nonoverriding Descriptors 665
Overriding Descriptor 667
Overriding Descriptor Without__get__ 668
Nonoverriding Descriptor 669
Overwriting a Descriptor in the Class 670
Methods Are Descriptors 671
Table of Contents I xiii
Descriptor Usage Tips 673
Descriptor docstring and Overriding Deletion 675
Chapter Summary 676
Further Reading 677
21. Class Metaprogramming.................................................. 681
A Class Factory 682
A Class Decorator for Customizing Descriptors 685
What Happens When: Import Time Versus Runtime 688
The Evaluation Time Exercises 689
Metaclasses 101 693
The Metaclass Evaluation Time Exercise 695
A Metaclass for Customizing Descriptors 699
The Metaclass__prepare__Special Method 701
Classes as Objects 703
Chapter Summary 704
Further Reading 706
Afterword................................................................... 709
A. Support Scripts............................................................ 713
Python Jargon............................................................... 741
Index....................................................................... 751
Table of Contents
|
any_adam_object | 1 |
author | Ramalho, Luciano |
author_GND | (DE-588)1077177372 |
author_facet | Ramalho, Luciano |
author_role | aut |
author_sort | Ramalho, Luciano |
author_variant | l r lr |
building | Verbundindex |
bvnumber | BV042940164 |
classification_rvk | ST 250 |
ctrlnum | (OCoLC)931313589 (DE-599)BVBBV042940164 |
discipline | Informatik |
edition | First edition |
format | Book |
fullrecord | <?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>01619nam a2200361 c 4500</leader><controlfield tag="001">BV042940164</controlfield><controlfield tag="003">DE-604</controlfield><controlfield tag="005">20211018 </controlfield><controlfield tag="007">t</controlfield><controlfield tag="008">151021s2015 a||| |||| 00||| eng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781491946008</subfield><subfield code="c">kart. : ca. EUR 53.70 (DE), $ 59.99 (US), $ 79.99 (CAN)</subfield><subfield code="9">978-1-491-94600-8</subfield></datafield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">1491946008</subfield><subfield code="9">1-491-94600-8</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)931313589</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DE-599)BVBBV042940164</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DE-604</subfield><subfield code="b">ger</subfield><subfield code="e">rakwb</subfield></datafield><datafield tag="041" ind1="0" ind2=" "><subfield code="a">eng</subfield></datafield><datafield tag="049" ind1=" " ind2=" "><subfield code="a">DE-11</subfield><subfield code="a">DE-473</subfield><subfield code="a">DE-83</subfield><subfield code="a">DE-384</subfield><subfield code="a">DE-Aug4</subfield><subfield code="a">DE-525</subfield><subfield code="a">DE-523</subfield><subfield code="a">DE-29T</subfield><subfield code="a">DE-20</subfield><subfield code="a">DE-706</subfield><subfield code="a">DE-521</subfield><subfield code="a">DE-862</subfield><subfield code="a">DE-703</subfield><subfield code="a">DE-860</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">ST 250</subfield><subfield code="0">(DE-625)143626:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Ramalho, Luciano</subfield><subfield code="0">(DE-588)1077177372</subfield><subfield code="4">aut</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Fluent Python</subfield><subfield code="b">clear, concise, and effective programming</subfield><subfield code="c">Luciano Ramalho</subfield></datafield><datafield tag="250" ind1=" " ind2=" "><subfield code="a">First edition</subfield></datafield><datafield tag="264" ind1=" " ind2="0"><subfield code="a">Beijing ; Boston ; Farnham ; Sebastopol, CA ; Tokyo</subfield><subfield code="b">O'Reilly</subfield><subfield code="c">2015</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">xxiv, 765 Seiten</subfield><subfield code="b">Illustrationen</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="b">txt</subfield><subfield code="2">rdacontent</subfield></datafield><datafield tag="337" ind1=" " ind2=" "><subfield code="b">n</subfield><subfield code="2">rdamedia</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="b">nc</subfield><subfield code="2">rdacarrier</subfield></datafield><datafield tag="500" ind1=" " ind2=" "><subfield code="a">Hier auch später erschienene, unveränderte Nachdrucke</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Python</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4434275-5</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="689" ind1="0" ind2="0"><subfield code="a">Python</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4434275-5</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2=" "><subfield code="5">DE-604</subfield></datafield><datafield tag="776" ind1="0" ind2="8"><subfield code="i">Erscheint auch als</subfield><subfield code="n">Online-Ausgabe</subfield><subfield code="w">(DE-604)BV043019674</subfield></datafield><datafield tag="856" ind1="4" ind2="2"><subfield code="m">HBZ Datenaustausch</subfield><subfield code="q">application/pdf</subfield><subfield code="u">http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=028366671&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="999" ind1=" " ind2=" "><subfield code="a">oai:aleph.bib-bvb.de:BVB01-028366671</subfield></datafield></record></collection> |
id | DE-604.BV042940164 |
illustrated | Illustrated |
indexdate | 2024-08-01T11:25:02Z |
institution | BVB |
isbn | 9781491946008 1491946008 |
language | English |
oai_aleph_id | oai:aleph.bib-bvb.de:BVB01-028366671 |
oclc_num | 931313589 |
open_access_boolean | |
owner | DE-11 DE-473 DE-BY-UBG DE-83 DE-384 DE-Aug4 DE-525 DE-523 DE-29T DE-20 DE-706 DE-521 DE-862 DE-BY-FWS DE-703 DE-860 |
owner_facet | DE-11 DE-473 DE-BY-UBG DE-83 DE-384 DE-Aug4 DE-525 DE-523 DE-29T DE-20 DE-706 DE-521 DE-862 DE-BY-FWS DE-703 DE-860 |
physical | xxiv, 765 Seiten Illustrationen |
publishDateSearch | 2015 |
publishDateSort | 2015 |
record_format | marc |
spellingShingle | Ramalho, Luciano Fluent Python clear, concise, and effective programming Python Programmiersprache (DE-588)4434275-5 gnd |
subject_GND | (DE-588)4434275-5 |
title | Fluent Python clear, concise, and effective programming |
title_auth | Fluent Python clear, concise, and effective programming |
title_exact_search | Fluent Python clear, concise, and effective programming |
title_full | Fluent Python clear, concise, and effective programming Luciano Ramalho |
title_fullStr | Fluent Python clear, concise, and effective programming Luciano Ramalho |
title_full_unstemmed | Fluent Python clear, concise, and effective programming Luciano Ramalho |
title_short | Fluent Python |
title_sort | fluent python clear concise and effective programming |
title_sub | clear, concise, and effective programming |
topic | Python Programmiersprache (DE-588)4434275-5 gnd |
topic_facet | Python Programmiersprache |
url | http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=028366671&sequence=000001&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |
work_keys_str_mv | AT ramalholuciano fluentpythonclearconciseandeffectiveprogramming |
Inhaltsverzeichnis
THWS Schweinfurt Zentralbibliothek Lesesaal
Signatur: |
2000 ST 250 P99 R165 |
---|---|
Exemplar 1 | ausleihbar Verfügbar Bestellen |