Index

Symbols

() characters

using, to break long statement into sensible pieces 60

* separator

about 127

used, for forcing keyword-only arguments 122, 124, 125, 127, 128

*, separator 127

** separator 127

/ separator

used, for defining position-only parameters 130, 132, 134

__slots__

small objects, optimizing with 297, 301, 302

A

Abstract Base Classes (ABCs) 146

abstract superclass 327

ACID properties

atomicity 729

consistency 729

durability 729

isolation 729

add method

used, for building sets

aggregation 310

alternate hypothesis 773

anonymous tuples

anscombe.json 734

append() method

used, for building lists 153

approaches, for designing functions with optional parameters

General to Particular design 104, 106

Particular to General design 102, 103, 104

argparse

using, to get command-line input 245, 247, 248, 250

arguments

processing, options

arrays 148

ASCII

creating

associative store 197

autocorrelation 764

computing 764, 766, 767, 768, 769, 770

long-term model 771

working 770

B

backslash

using, to break long statement into logical lines 58, 60

Beautiful Soup

reference link

block mapping 660

block sequence 660

block style

working 660

body elements

about 78, 79

recognizing, with RST parser 76

bootstrapping

break statements

used, for avoiding potential problem

built-in collection

extending

built-in statistics library

using 734, 736, 737, 739, 740, 741

bytes

decoding

versus strings

C

card model 564, 565, 566

Card objects

representation, transferring 564

Cascading Style Sheet (CSS)

Certificate Authority (CA)

characters

used, for building complicated strings 43

chunking 109

class-as-namespace

using, for configuration files 674, 676, 678, 679

class-as-namespace, for configuration files

configuration representation 682, 684

class definitions

type hints, using for 262, 264, 265, 267

used, for encapsulate class details 253, 255, 257, 258, 260

used, for processing class details 253, 255, 257, 258, 260

classes

designing, with processing 268, 269, 271, 273, 275, 276

classes, design alternatives for storing data

eager 269

lazy 269

classes, strategies for storing data

extend strategy 269

wrap strategy 269

class hierarchies

essential features 320

mixin features 320

class level variables

creating 335, 336

class with orderable objects

creating 346, 347, 348, 350, 351, 352

clear documentation strings

writing, with RST markup

CLI applications

combining 721, 722, 724, 726, 727, 729

unit testing 730, 731, 732

wrapping 721, 722, 724, 726, 727, 729

cmd class

cmd module

using, to create command-line applications

code rot 697

coefficient of correlation

computing 752, 753, 754, 755, 756

collaborators 255

collection

summarizing 408, 410, 411, 412

collections

transformations, applying to 374, 376, 377, 378, 381

collections module

built-in collections 148

combining two applications into one

about 691, 693, 695, 696, 697

complex sequences of steps, controlling

conditional processing, building

output, checking

program, wrapping as Python class

with Command Design Pattern 704, 706, 707

combining two applications into one, areas of rework

about 697

logging features 702, 704

performance 699, 701, 702

structure 699

come-out roll 81

Command Design Pattern

used, for combining two applications into one 704, 706, 707

command-line applications

creating, with cmd module

command-line input

obtaining, with argparse 245, 247, 248, 250

Command-Line Interface (CLI) 710

comma-separated value (CSV) 339

comma-separated values (CSV) 454

complex algorithms

simplifying, with immutable data structures

complex data structure

deserializing

serializing 489, 490

complex data structures

using 339, 341, 343

complex formats

reading, with regular expressions 469, 472, 478

complex formats, reading with regular expressions

log_parser() function, using 476, 478

parse function, defining 474, 476

complex if...elif chains

designing 81, 83, 84, 86

complex strings

building, with f strings 38, 39, 40

complex text

parsing 237, 239

complicated objects list

items, deleting

complicated strings

building, with characters 43

composite

composite application

arguments, managing 710, 712, 714, 715, 716, 717, 719

configuration, managing 710, 712, 714, 715, 716, 717, 719

creating 691, 695, 697

creating, issues 693

composite object validation 236

composites

creating, with combination of existing command 708, 710

composition 308, 309, 310

comprehension 154

configuration files

class-as-namespace, using for 674, 676, 678, 679

finding 643, 644, 646, 648, 650

Python, using for 666, 667, 668, 670

YAML, using for 655, 657, 659, 660

context managers

creating

contexts

creating

managing, with statement used

copy of list

reversing 181, 182, 183, 184

Counter object

average of values 745, 747, 748

Counter object, values

working 750, 772

Coupon Collector�s Test 268

crib 285

CSV dialect 454

csv DictReader

refactoring, as dataclass reader

CSV files

working with, dataclasses used 463, 464, 465, 466

CSV module

delimited files, reading with 454, 456, 457, 459

currency 8

currency calculations

performing 9, 10

D

dataclasses

used, for working with CSV files 463, 464, 465, 466

using, for mutable objects 285, 287, 288, 290

dataclass reader

csv DictReader, refactoring as

data structure

arrays 148

graphs 150

hashes 150

selecting 143, 144, 146, 148

trees 148

decimal

selecting 7, 8, 15, 17

Deck class 566, 569, 571

deep copies of objects

making

delimited files

reading, with CSV module 454, 456, 457, 459

del statement

used, for deleting items 167

used, for removing dictionaries 197, 199, 201, 202

dictConfig() function

using

dictionaries

building, as comprehension 192, 194

building, by setting items 192

building, ways 190

creating 189, 190, 194

inserting 189, 190, 194

removing, with del statement 197, 199, 201, 202

removing, with pop() method 197, 199, 201, 202

updating 189, 190, 194

updating, with statistical summaries 741, 742, 744, 745

dictionary-related type hints

writing 211, 213, 214, 215

difference() method

used, for removing items

difference_update()method

used, for removing items

directives

using 79

discrete integer-valued variable

docstrings

about 51

RST markup, writing 73, 75, 76

used, for testing 496, 498, 499

writing, for library modules 69

writing, for scripts 66, 68, 69

doctest examples

writing, for floating-point values 520

writing, with object IDs 519

writing, with unpredictable set ordering 518, 519

doctest issues

handling 514, 515, 517, 522

doctest module

working 504

doctest test cases

combining, with pytest test cases 549, 550, 551, 553

combining, with unittest test cases 537, 538, 539, 541, 542

doctest tool 55

document object model (DOM)

Document Type Definition (DTD)

Don�t Repeat Yourself (DRY) principle

E

edge cases

identifying 505

emergent behavior 255

end-to-end testing 491

escape sequences

except

clause

used, for avoiding potential problem

exception matching rules

leveraging

exception root cause

concealing

existential quantifier

explicit line joining 63

exploratory data analysis (EDA) 734

exponent 17

extend strategy 269

external resources

mocking

extra punctuation marks

removing 28

F

f 241, 243

files

replacing, while preserving previous version 445, 447, 449, 450

filter() function

used, for rejecting items 171

using 405

First-In-First-Out (FIFO) 304

First Normal Form (1NF) 454

Flask framework

using, for RESTful APIs 572, 574, 575, 576, 578, 579

Flask�s documentation

reference link 583

float

selecting 7, 8, 15, 17

floating-point

need for 17

floating-point approximations 11, 13

floor division

performing 20, 22

versus true division 19, 20

flow style 660

for statement

used, for applying parse_date() function to collections 378

fraction

about 8

selecting 7, 8, 15, 17

fraction calculations 10, 11

frozen dataclasses

using, for immutable objects 292, 294, 296

f strings

used, for building complex strings 38, 39, 40

function parameters

about 93, 95, 96

mutable default values, avoiding for

functions

designing, with optional parameters 101, 106, 108

testing, that raise exceptions 507, 508, 509, 511, 512

functools.partial()

using

G

garbage collection 318

general domain validation 235

generalization-specialization relationship , 308

generator expression

filter, using 403, 404

list function, using 154

set function, using

used, for applying parse_date() function to collections 378

generator expressions

patterns 383

generator functions 371

applications, creating 373

writing, with yield statement 363, 365, 366, 368, 369, 371, 372

get_optionsO function 719

getpass() function

using, for user input 229, 231, 232, 233, 235

global objects

managing 331, 332, 336, 337

global singleton variables

creating 334

sharing, ways 337

graphs 150

H

half-open interval 29

has-a relationship 308

hashes 150

header row

excluding 389

heterogenous items 175

higher-order function

hints 138

homogenous items 175

HSL

converting, to RGB 98, 100

HTML documents

reading

Hypertext as the Engine of State (HATEOS) 622

I

immutable data structures

used, for simplifying complex algorithms

immutable objects

frozen dataclasses, using for 292, 294, 296

typing.NamedTuple, using for 280, 282, 283

immutable string

rewriting 24, 25, 29

implicit line joining 63

index-only tuples

inheritance 308, 309, 310, 314, 315, 316

inline markup

using 80

input() function

using, for user input 229, 231, 232, 233, 234, 235

instances 254

intermediate results

assigning, to separate variables 62

saving, with walrus operator 87, 89, 90

int() function, signatures

int(str) 101

int(str, base) 101

irrational numbers 8

is-a relationship 308

items

deleting, form lists 166, 172

deleting, from complicated objects list

deleting, with del statement 167

deleting, with pop() method 169, 171

deleting, with remove() method 169

extracting, from tuples

rejecting, with filter() function 171

removing, with difference() method

removing, with pop() method

removing, with remove() method

replacing, with slice assignment 172

iterator 369

itertools module

about

additional functions

J

JavaScript Object Notation (JSON)

URL 482

JSON-based error messages

creating

JSON documents

reading 482, 484, 485, 486

structures 486

JSONLines

URL 488

JSON request

parsing 631, 632

parsing, for client 639

parsing, for sever 636, 638, 639

parsing, OpenAPI specification 633, 635

parsing, with additional resources

parsing, with location header

JSON syntax

data structures 659

K

keyword-only arguments

forcing, with * separator 122, 124, 125, 127, 128

keyword parameters

disadvantage 121

used, for creating partial function

using 114, 116, 118, 120

L

lambda object

creating

large integers

working with 3, 5, 6

Last-In-First-Out (LIFO) 304

Law of the Excluded Middle 81

lazy attributes

properties, using for

lazy calculation

working

leaks

library modules

docstrings, writing for 69

line joining 63

Liskov Substitution Principle (LSP) 708

list comprehension

writing 154

list function

using, on generator expression 154

list-related type hints

writing 175, 176, 177, 179

lists

building 150, 151, 156

building, with append() method 153

dicing 160, 161, 162, 163, 164, 165

extending ways 157, 159

slicing 160, 161, 162, 163, 164, 165

lists, building ways

append method 151

comprehension 151

conversion function 151

generator expressions 152

literal 151

load_config_file() funtion

implementing, ways 646

load testing 491

logging.config module

using

logging module

used, for auditing output

used, for controlling output

logging package

severity levels

long lines of code

writing 56, 58

M

magic 55

mantissa 17

map

combining 416, 418, 420, 421, 422, 423, 425

map() function

used, for applying parse_date() function to collections 379

using 381, 383

maps of lists

using 339, 341, 343

Median Absolute Deviation (MAD) 786

memorization technique

Method Resolution Order (MRO) 323, 683

modeline 56

modules, for writing summary docstrings

library modules 64

scripts 64

multiple contexts

managing, with multiple resources

multiple inheritance

concerns, separating via 319, 320, 321, 322, 323, 324

multiset 150, 304, 356

creating, ways 356

mutable default values

avoiding, for function parameters

mutable objects

dataclasses, using for 285, 287, 288, 290

Mypy documentation

reference link 100

mypy tool 93

N

NamedTuples

using, to simplify item access in tuples

Newline Delimited JSON

URL 488

null hypothesis 275, 773

numbers type

converting 13

O

Object-Relational Management (ORM) layer 693

objects 253

Observable design pattern 324

Observer design pattern 324

optional parameters

type hints, designing for 109, 111, 113

used, for designing functions 101, 106, 108

ordered collection

performance, improving with 354, 357, 358

order of dictionary keys

controlling 205, 207, 208

OS environment settings

using

outliers

locating 785, 786, 787, 788

overloaded function 101

P

parameters order

picking, based on partial functions

partial function

creating

partial functions

creating, with keyword parameters

creating, with positional parameters

order of parameters, picking based on

wrapping

pass_outliers() function

versus reject_outliers() function

pathlib

using, to work with filenames 430, 432, 433, 434

pathname manipulations

directory, creating in directory 436

file dates, comparing 438

files, creating in directory 436

files, removing 438

files with matching patterns, finding 439, 441

output filename, making by changing input filename�s suffix 434

sibling output files, making with distinct names 434, 436

Pearson�s r 752

percent encoding 589

piece of string

slicing 25, 27

pop() method

used, for deleting items 169, 171

used, for removing dictionaries 197, 199, 201, 202

used, for removing items

positional parameters

used, for creating partial function

position-only parameters

defining, with / separator 130, 132, 134

potential problem

avoiding, with break statements

avoiding, with except

clause

prefixes

alternate form 40

fill and alignment 40

leading zero 40

sign 40

width and precision 40

print() function, features

using 220, 222, 224, 225, 227

pure paths 646

pytest module

used, for unit testing 543, 544, 546, 547, 548

pytest test cases

combining, with doctest test cases 549, 550, 551, 553

pytest tool 494

Python

advantages 722

features 729

URL 6

using, for configuration files 666, 667, 668, 670

Python Enhancement Proposal (PEP) 8 60

Python Enhancement Proposal (PEP) 484

reference link 55

Python module files

writing 47, 49, 51, 53, 55

Python Package Index (PyPI)

reference link

Python script

writing 47, 49, 51, 53, 55

Python�s duck typing

leveraging 327, 328, 330

Python�s stack limits

recursive functions, designing around

pyyaml project

reference link 482

Q

query string

parsing, in request 583, 586, 587, 589

R

Rate-Time-Distance (RTD) 116

rational fraction calculations 22, 24

rational numbers 8

read-evaluate-print loop (REPL)

recursive functions

designing, around Python�s stack limits

recursive generator functions

writing, with yield from statement

reduce() function

application, designing 412

drawback 414

using, to customize maxima 414

using, to customize minima 414

reduction

reference counting 318

references 217, 218

regression algorithm 761, 763

regression parameters

computing 758, 759, 760, 761

Regular Expression (RE) 32

regular expressions

complex formats, reading with 469, 472, 473, 478

used, for parsing strings 32, 34, 35, 36

reject_outliers() function

versus pass_outliers() function

remove() method

used, for deleting items 169

used, for removing items

Representational State Transfer (REST) 561

RESTful 561

RESTful APIs

Flask framework, using for 572, 574, 575, 576, 578, 579

RESTful APIs, with Flask

features, adding to sever 622

OpenAPI specification, providing for parsing URL path 624, 626, 627

OpenAPI specification, using for parsing URL path 629

URL path, parsing 608, 610

URL path, parsing at client side 620, 622

URL path, parsing by slicing deck of cards 620

URL path, parsing for client 616, 617, 618, 619

URL path, parsing for sever 610, 612, 614, 615

URL path, parsing with CRUD operations 619

REST requests

making, with urllib 593, 595, 596, 598, 600

ReStructuredText (RST) markup 66

RGB

converting, to HSL 98, 100

row_merge() function

creating, to restructure data 387, 388

RST markup

used, for writing clear documentation strings

writing, in docstrings 73, 75, 76

RST parser

body elements, recognizing 76

S

schema 454

script descriptions 64, 66, 69

script documentation 64, 66, 69

script-library switch

used, for writing testable scripts

scripts

designing, for composition 685, 687

docstrings, writing for 66, 68, 69

refactoring, to class

Secure Socket Layer (SSL) protocol 601

separate tests directory 535

set comprehension

writing

set function

using, on generator expression

set-related type hints

writing

sets

building 184, 186

building, with add method

sets, building ways

add method

comprehension

conversion function

generator expressions

literal

shallow copies of objects

making

shallow copy 165

shebang 55

signature 101

singleton objects

managing 331, 332, 336, 337

slice assignment

used, for replacing items 172

slice operator 164

small integers

working with 3, 5, 6

S.O.L.I.D. design principles

Dependency Inversion Principle 262

Interface Segregation Principle 261

Liskov Substitution Principle 260

Open/Closed Principle 260

Single Responsibility Principle 260

sophisticated collections

using 303, 304, 306

Sphinx Python Documentation Generator

reference link 80

spike solution

reference link 724

src 539

stacked generator expressions

using 383, 384, 386, 391, 392, 393, 395, 397

string literal concatenation

using 61

strings

encoding

parsing, with regular expressions 32, 34, 35

updating, with replacement 27, 28

versus bytes

subdomain validation 235

subset

selecting, to filter data 397, 399, 401, 403, 405, 406

summary of data, EDA

central tendency 734

extrema 734

variance 734

Swagger 603

T

tail recursion

takewhile() function

testable scripts

writing, with script-library switch

TestCase class 535

assertion methods 532

testing

docstrings, using for 496, 498, 499

testing, with docstrings

examples, writing for stateful objects 501, 503, 504

examples, writing for stateless functions 499, 501

tests 535

writing, with datetime object 555, 556, 557, 559

test tool setup 492, 494

text role 80

there exists processing pattern

implementing

transformations

applying, to collections 374, 376, 377, 378, 381

reducing 416, 418, 420, 421, 422, 423, 425

trees 148

true division

about 24

performing 22

versus floor division 19, 20

truncated division 24

tuples

creating

item access, simplifying with NamedTuples

items, extracting from

tuples of items

using

type hints

about 93, 95, 96

designing, for optional parameters 109, 111, 113

using, for class definitions 262, 264, 265, 267

writing, for complex types 134, 136, 138, 139

typing.NamedTuple

using, for immutable objects 280, 282, 283

U

Unicode characters

reference link

using

Unicode encodings

reference link

unit test algorithm

with randomness

unit testing

with pytest module 543, 544, 546, 547, 548

with unittest module 523, 525, 526, 527, 529, 531

unittest module

used, for unit testing 523, 525, 526, 527, 529, 531

unittest test cases

combining, with doctest test cases 537, 538, 539, 541, 542

URL encoding

rules 589, 591

urllib

REST requests, making with 593, 595, 596, 598, 600

urllib, using for making REST requests

OpenAPI resource, adding to sever 604, 605, 607

OpenAPI specification 603

useful row objects

creating 390, 391

user authentication 601

User Experience (UX) 712

user interaction

via cmd module 239

UTF-8 bytes

creating

UTF-8 encoding

reference link

V

variables 217, 218

analyzing, in one pass

variables, categories

categorical data

continuous real-valued data

count data

discrete data

ordinal data

W

walrus operator

about 47

used, for saving intermediate results 87, 89, 90

web services

HTTP basic authentication

HTTP bearer token authentication

web services authentication

example client, creating

implementing

server, creating

server, starting

User class, defining

view decorator, defining

web services authentication, parts

best practices, using for password hashing

decorator, using for secure view functions

SSL, using to provide secure channel

web services, authentication ways

certificates

HTTP headers

Web Services Gateway Interface (WSGI) 562, 579

web services, HTTP-based authentication

Flask view function decorator, using for

SSL, configuring for

user credentials, rules

web services, security implementation parts

authentication

authorization

with statement

used, for managing contexts

wrapping 312, 313, 314

aggregation 312, 313, 314

composition 312, 313, 314

wrap strategy 269

X

XML

XML documents

reading

XML Path Language (XPath)

Y

YAML

features 662

features, examples 662, 663, 665

URL 482, 659

using, for configuration files 655, 657, 659, 660

YAML document

reading 482

yield from statement

used, for writing recursive generator functions

yield, from statement

used, for writing recursive generator functions

yield statement

used, for writing generator functions 363, 365, 366, 368, 369, 371, 372

Z

z-scores

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset