dead_simple_python_index

Dead Simple Python Index

Symbols

Symbols

!= (not equals) operator, 49

!a (ASCII flag), 58

!r (representation flag), 58

!s (string flag), 58

“ (single quotes), 43, 54

”“ (double quotes), 43, 54

”“” (triple quotes), 43, 54–55, 57

alternative form flag, 58

hash or octothorpe, 42

  1. ! (haSH-BANG or shebang) command, 24–25

$ string notation, 61

% operator

modulo, 46, 47

string notation, 59–60

%-interpolation, 346

& (and/intersection) operator, 47, 221, 343–344, 345

() (parentheses) operator, 46

multiplication, 46

starred expression, 226

variadic parameter, 130–131

wildcard, 527

** operator

exponent, 46

keyword variadic parameter, 131

+ operator

addition, 46

concatenation, 56, 62

flag, 58, 298

, (trailing comma), 126, 217, 226

- operator

sign flag, 58

subtraction/difference, 46, 221

→ (return type annotation) operator, 146

. (current directory), 322

. (dot) operator, 58, 64, 152, 429

.. (parent directory), 84, 322

… (Ellipsis), 53, 146

prompt, 18

/ (forward slash) operator

division, 46

in paths, 318, 321

in positional parameters, 133

// (floor division) operator, 46, 47

: (colon), 42, 63, 222, 279

:= (assignment expression/walrus) operator, 52–53

; (semicolon), 40

< operator

align left flag, 58

less than, 49

⇐ (less than or equals) operator, 49

« (left shift) operator, 47, 345

== (equals) operator, 49, 97–98

= operator

alignment flag, 58

assignment, 44, 47

align right flag, 58

greater than, 49

= (greater than or equals) operator, 49
(right shift) operator, 47, 345

@ operator, 47, 144

[] (square brackets), 65–66, 222, 277

\ (backslash) character, 54, 55–56

\n (newline), 55, 56, 294, 307

\t (tab), 293–294

\r (carriage return), 294, 307

align center flag, 58

exclusive or/symmetric difference, 47, 221, 344, 345

_ (underscore) character

as name, 226, 227

nonpublic flag, 156

as wildcard, 68

__ (naming convention), 157, 167

{} (curly braces), 57, 61, 220, 222, 278, 279

~ (tilde) character

bitwise inversion operator, 47, 344–345

in UNIX folder system, 321–322

0 (leading zeros flag), 58

A

abs() (absolute) function, 46

__abs__() method, 174, 641

absolute imports, 83

absolute paths, 316–320, 325

abstract base classes (ABCs)

about, 410–411

built-in, 411–412

custom, 415–417

deriving from, 412–415

abstract syntax tree (AST), 571

@abstractmethod decorator, 415

accelerator modules, 629

accumulate() (itertools module) function, 252

acquire() method, 493

__add__() method, 174, 640

add() method, 220, 250–251

addition (+) operator, 46, 298

__aenter__() method, 475, 639

Aesera, 625–626

__aexit__() method, 475, 639

aioconsole library, 469–470

__aiter__() method, 473, 639

aliases and aliasing

about, 117

function names, 80

mutable data types, 108, 110

with type hints, 146

alignment flags, 58

all() function, 248

Anaconda, 35–36, 624, 625

anchors, 316–317

__and__() method, 174, 345, 642

and operator, 51–52

__anext__() method, 473, 639

annotations, 145–147

__annotations__ attribute, 146, 645

anonymous callables, 652

anti-pattern examples, 86, 131, 150, 190–192, 374, 385

any() function, 248

append() method, 218

append writing, 298

appendleft() method, 220

AppImage, 538–539

Appium-Python-Client, 602

application development, 621–622

arbitrary arguments lists. See variadic arguments

arbitrary execution, 454–456, 652

argparse, 554

arguments

about, 123, 652

default values, 126–128

keyword and positional, 128–129

variadic, 130–132

arithmetic shift operations, 345

ArithmeticError class, 209

Arnold, Tim, 626

arrays, 219

artifacts, 652

as (alias) keyword, 80

ASCII characters, 58, 346

ascii() function, 61

Åsheim, Eiríkr, 486

assembled languages, 5

assembling, 6

AssertionError, 556–557

assertions (assert statements), 556–560, 653

assignment, 107–109, 117. See also binding

assignment expressions, 44, 47, 52–53, 369–370

async for statement, 474

async keyword, 464, 653

async with statement, 475

asynchronous context managers, 475

asynchronous generators, 475

asynchronous iteration, 472–475

asynchrony

advanced concepts, 475–476

and coding safety, 486

in Collatz game example, 465–469

with context managers, 475

with generators, 475

with iterations, 472–475

in Python, 459–460

scheduling and execution flow, 470–472

vs. threading, 478

uses of, 463–464

asyncio module, 460, 464–468

atexit module, 102

atomic operators, 488

AttributeError, 157, 164, 209

attributes

about, 150, 154, 653–654

checking for, 408–410

class, 105–106, 154, 155–156

deleting, 433

of functions, 433–436

inspecting, 426–431

instance, 151, 152, 154–155

scope naming conventions, 156–157

setting, 431–433

and structural pattern matching, 177–180

Atwood, Jeff, 185

augmented assignment operators, 47

automation development, 627

autopep8 tool, 33

autouse fixtures, 603–604, 665

await keyword, 464–465

__await__() method, 639

awaitables, 464

B

backslash (\) character, 54, 55–56, 347

Bandit, 571–574

bare getters and setters, 150

BaseException class, 207, 209

__bases__ attribute, 646

basicConfig() (logging module) function, 196, 199

Batchelder, Ned, 95, 99, 107, 456, 609

bdist (built distribution), 516, 531

Beazley, David, 460

benchmarking, 611, 612–613

big data, 623

big-endian byte order, 342–343, 349

bin() function, 341, 343

binary extension modules, 629–630

binary notation, 338–343

binary operator special methods, 173–174

binary streams

about, 295

BufferedRWPair stream, 372

changing stream positions, 371

custom format example, 364–368

modes, 298

opening, 363

reading from, 368–370

binding. See also assignment

about, 117, 654

to copies, 111–114

names and values, 97–98

references, 109

weakly bound, 44

binding behavior, 436, 655

bitmasks, 341

bits, 338

bitwise operations

on bytes-like objects, 357–361

and custom classes, 346

operators, 47, 343–346

black box behaviors, 150

Black tool, 34

boilerplate code, 151

Bokeh, 624

bool() function, 237–238

__bool__() method, 171, 638

boolean values, 51, 237–238, 345

boolean variables, 50–51

break statement, 67, 214

breakpoints, 561

brittle code, 247, 556

Brython (Browser Python), 623

BSON serialization format, 376

bubbling up, 199–200

buffer protocol, 361

BufferedRWPair stream, 372

BufferError, 209

buffers, 291–292, 655

build system (pyproject.toml), 529–530

built distribution (bdist), 516, 531

built-in importer, 90

__builtins__, 645

bullet journal example, 385–388

bytearray objects, 348, 363

bytecode, 6, 91

byteorder attribute, 349

bytes

defined, 338

order, 342–343, 349–350, 352, 656

bytes() method, 348–349

__bytes__() method, 171, 638

bytes-like objects

about, 347

bitwise operations on, 357–361

bytes vs. bytearray, 348

creating, 348–349

and integer conversions, 349–351

and memory consumption, 361–363

sequence operations, 351

and struct module, 352

bytes literals, 346–347

BytesWarning, 545

C

C Foreign Function Interface (CFFI), 629

C3 Method Resolution Order (C3 MRO), 389–392, 395

__cached__ attribute, 644

cached bytecode, 91

Call for Proposals (CFPs), 634

__call__() method, 175–176, 638

call stacks, 186–187

callable instances, 175–176

callable objects (callables), 131–132, 656

callbacks, 465

camel case, 656

canonical string representation, 61, 168–169

capture patterns, 69–70

cargo cult programming, 514, 657

carriage return (\r), 294, 307

CBOR (Concise Binary Object Representation) serialization format, 376

__ceil__() method, 171, 638

chain() (itertools module) function, 252

chr() function, 161

chunking, 501

CircuitPython, 627

__class__ attribute, 645

class attributes, 105–106, 646

__class_getitem__() method, 644

class methods, 158–159

classes. See also abstract base classes (ABCs); inheritance; metaclasses; virtual subclasses

about, 150

base vs. derived, 384

and bitwise operations, 346

decisions about using, 181–182

declaring, 151–154

as immutable, 447–449

and SOLID principles, 382–384

syntax, 63–64

classifiers (PyPI), 522–523

@classmethod decorator, 159

clauses, 657

click module, 579–580, 615

close() method, 265, 296, 297

closing generators, 264–266

__closure__ attribute, 645

closures, 135–138

coarse-grained locking, 487–488

code

autoformatting, 33–34

boilerplate, 151

brittle, 247, 556

dead”, 608

editors, 34–36

frozen, 666

security evaluation, 571–574

style, 27–29, 31

testing frameworks, 34

and thread safety, 486–488

tightly coupled, 120

__code__ attribute, 645

code coverage, 607–609

code injection, 455

coercion, 114, 117, 658

Collatz game example

with asynchronous iterable, 472–473

with coroutines, 465–472

with futures, 483–486, 496–497

with multiprocessing, 500–501

producer/consumer implementation, 502–507

with queue, 495–496

with race conditions, 489–493

synchronous version, 461–463

threading, 479–481, 482

collections

about, 65, 66, 216

checking for values in, 236–237

deques, 219–220

dictionaries, 222–225

length, 237–238

lists, 218–219

and references, 109–114

sets, 220–222

subscriptable, 231

tuples, 216–218

unpacking, 225–228

collections module, 217, 411

combinations() (itertools module) function, 252

command line prompts, 18

comments, 42–43

comparison methods, 171–173

comparison operators, 49

compile() function, 454–456

compiling, 6

__complex__() method, 171, 638

complex numbers (complex), 45

compositions, 150–151, 181, 384

compound statements, 41

concatenations

in printing, 292

string literals, 55

strings, 56, 62

concrete exceptions, 209–210

concrete paths, 316

concurrency, 458, 478

concurrent.futures module, 483–486, 496–497, 508

conditionals, 41, 49, 273–276. See also ternary expressions

conferences, 634

configobj library, 333

configparser module, 332

configuration files, 332–333, 334

constants, 44–45, 47–48

constructors, 152–153

containers, 537–539

__contains__() method, 237, 254, 639

context management protocol, 309–314

context managers

about, 296–297

asynchronous, 475

operations, 308–314

context variables (contextvars), 476

continue statement, 67

controller class]]es, 384

conversions, 114–115, 117, 168–171

copy() function, 111

copying, 111–114, 117, 235

core developers, 631, 659

coroutines

about, 282–283, 287

native, 464–466

simple, 283–286

count() (itertools module) function, 258

Counter, 224

coverage.py tool, 607

cprofile module, 613–617

CPU-bound tasks, 463, 497–498

CPython, 5, 627, 628

CSV (comma-separated values) file format, 332

ctrace module, 607

cumulative runtime, 614

Curio library, 460, 466, 468

current working directory, 322, 324–325

cx_Freeze, 5, 6, 536

cycle() (itertools module) function, 258

Cython transpiler, 5, 630

D

daemonic threads, 482–483, 660

Dask, 624

data

defined, 117

as packaged files, 524

picklable, 499

data descriptors, 437

data hiding, 157

data science, 623–625

data types

in binary data conversions, 353

mutable and immutable, 106–107

treatment in Python, 44, 98–100

data validation vs. assertion, 558–559

dataclasses, 449

dataframes, 624

deactivate command, 20

deadlocks, 493–494

debugging. See also logging; Python Debugger (pdb)

and assertions, 556–560

example, 561–562

loops vs. generator expressions, 281–282

and packaging, 514–515

tools, 560–561

undefined behavior, 570–571

and warnings, 544–548

Decimal number type, 45–46

declarative programming, 120

decode() method, 368

decorators

about, 660

class, 176–177

defining properties with, 164–166

on functions, 142–145, 436

deep copy (deepcopy()), 113–114, 117

def keyword, 63

default argument values, 126–128, 146

defaultdict, 224

__defaults__ attribute, 645

__del__() method, 154, 643

del operator, 154, 223

delattr() method, 433

__delattr__() method, 433, 643

__delete__() method, 437, 639

deleters, 162–163

__delitem__() method, 231, 235, 639

dependencies, 15–16, 22–23, 524–525, 537–539

dependency injections, 587

Dependency Inversion Principle, 383–384

DeprecationWarning, 545

deques (deque), 219–220, 495

descriptors

about, 436–437, 661

using multiple, 442–444

writing, 437–442

deserialization. See serialization

design patterns, 373, 407–408

development environments. See also IDEs (integrated development environments)

and requirements.txt file, 528–529

dialects, 332

diamond inheritance problem, 389

diaper anti-pattern, 190–192

dice roll program example

basic function, 122–123

closures, 135–138

with default arguments, 125–128

with keyword arguments, 128–134

with recursion, 124–125, 134–135

with type hints, 145–146

__dict__ attribute

about, 426–428, 645, 646

listing, 428–429

vs. slots, 444–445

dict type, 222

dictionaries

about, 222–224

unpacking, 227–228

variants, 224–225

dictionary comprehensions, 279

difference (-) set operator, 221

dir() function, 429

__dir__() method, 429, 643

directories. See also paths

dist/, 531

and project structure, 74–77

src/, 517–518, 580

virtual environment, 19, 23–24

discard() method, 221

dist/ directory, 531

division (/) operator, 46

divmod() function, 47

__divmod__() method, 174, 640

Django, 622

__doc__ attribute, 644, 645, 646

Docker, 539

docstrings, 43, 58, 434, 541, 662

documentation

project, 540–541

Python, 9

with type hints and annotations, 145–147

dot operator (.), 64, 105, 152, 429

drive (in path names), 318, 319

dropwhile() (itertools module) function, 252

duck typing, 100, 114, 146–147, 384, 408–410

dump() (json module) function, 329–330

dumps() (json module) function, 329–330

dunder methods. See special methods

dynamic vs. static typing, 6, 44, 98–99

E

e (Euler's number) constant, 48

EAFP (Easier to Ask Forgiveness than Permission)

catching exceptions, 223, 408

philosophy, 187–188

eager iterables, 258, 662

Eclipse, 36

editable package installations, 531

eggs (format), 516

Element class example

definition, 445–446

functions, 449–452

as immutable, 447–449

usage, 452–454

elif statements, 49

Ellipsis (…), 53, 146

else clause, 41, 49, 202–204, 215–216

Emacs, 34–35

embedded development, 626–627

empty() method, 505, 506

empty sets, 221

encapsulation, 150, 182, 663

enclosing scope, 105

encode() method, 365

encoding= keyword, 349

encryption, 373–374

end= keyword, 292, 294

endianness, 342–343

__enter__()]] method, 308–309, 311, 638

entry points, 85–86, 86–87, 88–89, 525–526

enumerate() iterable, 244, 248

env/ directory, 19

EOFError, 198

__eq__() (equals) method, 170, 172, 640

equals, 49, 97–98, 172

Eric Python IDE, 36

errors, 663. See also debugging; exceptions

escape characters, 54, 55–56, 61, 347

eval() function, 454–456

event handler functions, 504

event loops, 459–460, 468

example projects. See Collatz game example; dice roll program example; Element class example; GlobalCoordinates class example; omission project example; SecretAgent class example; textproof project example; Timecard packaging example

except clause, 187, 189–190, 200

Exception class, 207, 209

exceptional state, 190

exceptions

about, 184–186

bubbling up, 199–200

catching, 64–65, 187–190

chaining, 200–202

vs. checking, 223–224

converting from warnings, 548

creating custom, 207–208

and diaper anti-pattern, 190–192

and dictionaries, 223–224

extracting information with, 194–195

list of, 208–210

and logging, 195–199

raising, 192–194, 408

throwing, 266–268

and tracebacks, 186–187

exec() function, 454–456

executors, 484–485

exists() (path module) method, 326

exit() command, 18

__exit__() method, 308–309, 311–312, 638

exponent (**) operator, 46

expressions, 40

extension development, 629–630

F

f (f-string) keyword, 56–57

f-strings (formatted strings), 56–60

fail-fast principle, 408

False and True values, 51, 237–238, 345

FastAPI, 623

faulthandler module, 570–571

__file__ attribute, 325, 426, 644

file formats, 328–335

file modes, 297–299, 303

file objects. See streams

file paths. See paths

FileHandler objects, 550–551

FileNotFoundError, 204, 209

files. See also JSON files; paths; streams

closing, 296–297

encoding systems, 25–26

opening, 295–296, 297–299

Python code (.py) files, 18, 75

reading, 299–302

replacing, 327–328

writing to, 303–307

filter iterable, 249, 277–278

Filter (logging module) objects, 555

filterfalse() (itertools module) function, 252

finalizers, 153–154

finally clause, 204–207

finder objects, 90

find_packages() function, 523

fine-grained locking, 488

first-class citizens, 62, 119

Fitzpatrick, Martin, 622

fixtures, 586–588, 664–665

Flake8, 31–33, 530

.flake8 files, 32

flaky tests, 591

Flask, 622–623

Flatpak, 537–538

Flit, 534

float() function, 46

__float__() method, 171, 638

floating-point numbers (float), 45, 46, 106, 353, 354, 665

floor division (//) operator, 46, 47

__floor__() method, 171, 638

__floordiv__() method, 174, 640

flush= keyword, 292

flushing, 291–292

fman Build System, 536–537

Foerster, Daniel, 360

for loops, 67–68, 215–216, 242–244

format() function, 59–60

__format__() method, 171, 638

format specifications

binary data conversion, 352–353

f-strings, 58–59

For[[matter (logging module) objects, 555–556

Fraction number type, 45–46

Freeze, 5

freezers, 5, 535–537

freezing, 665

from_bytes() method, 351

frozen importer, 90

frozen modules, 90

frozenset, 221–222

function annotations, 145–146

function attributes, 433–436

functional programming, 119, 120–122, 180

functions

aliases, 80

with lambdas, 140–141

list of special attributes on, 645

and methods, 64

nested, 104–105, 134–135

overloaded, 129–130

passing, 139–140

pure, 121–122

shadowing, 79–80, 81–82

side effects, 108

single-dispatch generic, 449–452

syntax, 62–63

functools module, 143, 144

__future__() module, 620

futureproofing, 373

futures, 666. See also concurrent.futures module

FutureWarning, 545

fuzzing, 605

G

Gábor, Bernát, 519

game development, 622

garbage collection, 100–101, 106, 153–154, 667

gather() (asyncio module) function, 472

__ge__() method, 173, 410, 640

generational garbage collection, 106

generator expressions

about, 123, 270–271

coding practices, 279–282

with conditionals, 273–276

evaluation of, 271–272

vs. list comprehensions, 277–278

with multiple loops, 272–273

with nesting, 276–277

generator functions

about, 259–261

closing, 264–266

vs. iterator classes, 261–263

throwing exception with, 266–268

and yield from statements, 268–270

generator iterators, 259–260

GeneratorExit, 264, 265–266

generators

asynchronous, 475

as coroutines, 286

vs. generator expressions, 282

generic functions. See single-dispatch generic functions

generic types, 146

__get__() method, 437, 639

getattr() function, 429

__getattr()__ method, 429–431, 643

__getattribute()__ method, 429–431

get_event_loop() function, 468

__getitem__() method, 231, 235, 639

__getstate__() method, 499

getters, 150, 161–163

Git, 23–24, 74

.gitignore file, 24, 74

Glassner, Andrew, 626

glob module, 315

glob() (path module) method, 326

glob patterns, 527

Global Interpreter Lock (GIL), 459, 478, 498

global keyword, 103, 105

global scope, 100, 102–104, 105

GlobalCoordinates() class example, 167–170, 172, 173, 174, 175–176

__globals__ attribute, 645

globals() function, 429

god classes, 181, 385, 667

Goldberg, David, 45

graft keyword, 527

greater than, 49, 172–173

grouping flag, 58

__gt__() (greater than) method, 172–173, 640

GTK GUI framework, 621

guard statements, 70–71

GUI frameworks, 621–622

H

happy paths, 188, 668

hardware

and embedded development, 626–627

package deployment on, 541

has-a relationships, 151

hasattr() function, 408–410, 431

__hash__() method, 170, 220, 639

hash values, 91, 170, 668

hashable objects, 220

Hashemi, Mahmoud, 515, 535

hashmaps, 222

HDF (Hierarchical Data Format), 376–377

headers, 41

heterogeneous collections, 66

Hettinger, Raymond, 395

hex() function, 341

hexadecimal numbers, 338–340

hexspeak, 339–340

high-performance computing (HPC), 497

hint= keyword, 301

home() (PosixPath module) method, 321

homogeneous collections, 66

hooks, 90, 668

HTML file format, 333

human-readable string representation, 61, 169–170

Hungarian Notation, 115–116

Hypothesis framework, 579

I

__iadd__() method, 174, 641

__iand__() method, 174, 643

id() function, 98

identity

defined, 117

operator (is), 50–51

and values, 97–98

IDEs (integrated development environments), 34–36, 145–146

IDLE, 34

if clauses, 41, 49

__ifloordiv__() method, 174, 642

__ilshift__() method, 174, 643

__imatmul__() method, 174, 642

immutable objects

about, 65–66, 117, 216

data types, 106–107

making classes as, 447–449

__imod__() method, 174, 642

import command, 26

__import__() method, 90, 643

import statement, 77

importer objects, 90

ImportError, 209

importlib module, 90

imports

absolute vs. relative, 83–85

cont[[rolling, 87–88

executing, 77

of explicit functions, 81–82

and namespaces, 78–79

from nested packages, 80–81

process, 90–91

and shadowing prevention, 79–80

ImportWarning, 545

__imul__() method, 174, 641

in operator, 67, 236–237

indentation, 29, 41

IndentationError, 210

__index__() method, 171, 638

IndexError, 209

indices (subscripts), 217, 231–235

inf (infinity) constant, 45, 47, 48

infinite iterators, 258–259

information security (infosec) field, 626

inheritance. See also method resolution order; multiple inheritance

about, 151, 382

bullet journal example, 385–388

and slots, 446

and SOLID principles, 382–384

when to use, 384–385

INI file format, 332–333

__init__() method, 64, 151–152, 643

__init__.py file, 74–75, 76, 86, 87–88

__init_subclass__() method, 643

initializers

methods, 151–152, 159

with multiple inheritance, 396–398

input() function, 40, 294–295, 469

inputs

mocking, 592, 597–598

validation vs. assertion, 558–559

insert() method, 219

inspect module, 560

instance attributes, 151–152, 645

instance methods, 158

__instancecheck__() method, 418, 643

instances

about, 150, 670

making callable, 175–176

__int__() method, 171, 638

integers (int), 45, 106, 340–341, 343

integrated development environments (IDEs), 34–36, 145–146

integration tests, 605

interactive sessions, 17–18

Interface Segregation Principle, 383

interfaces

and abstract base classes, 410–411

in SOLID principles, 382, 383

and virtual subclasses, 418

interpreted languages, 5

interpreter shutdown, 102

intersection (&) set operator, 221

introspection, 425, 426, 454, 670

__inv__() method, 345

invalid number constant (nan), 45

__invert__() method, 174, 345, 642

IO-bound tasks, 464

__ior__() method, 174, 643

__ipow__() method, 174, 642

IronPython, 628

__irshift__() method, 174, 643

is not operator, 51

is operator, 50–51, 97–98

is-a relationships, 151, 382

is_absolute() (path module) method, 326

is_dir() (path module) method, 326

is_file() (path module) method, 326

is_symlink() (path module) method, 326

isdigit() function, 188

isinstance() function, 99

islice() (itertools module) method, 235–236, 252

issubclass() method, 387

__isub__() method, 173, 174, 641

items() method, 228

iter() function, 240

__iter__() method, 238–239, 255, 638

iterables

about, 238

custom classes, 253–256

tools, 248–252

type-hinting, 147

iteration. See also iterables; loops

about, 215, 238–239

asynchronous, 472–475

with for loops, 242–243

manual, 239–241

tools for, 248–251

iterator classes vs. generator functions, 261–263

iterators

generator iterators, 259–260

infinite, 258–259

and lazy evaluation, 257–258

streams as, 301–302

iterdir() (path module) method, 326

itertools module, 252

__itruediv__() method, 174, 642

__ixor__() method, 174, 643

J

JetBrains, 35

join() method, 62

joinpath() method, 321

JSON (JavaScript Object Notation) files, 329–332

json module, 329

Jupyter Notebook, 623

just-in-time (JIT) compilers, 627

Jython, 628

K

Kedro, 624

Keen, Kyle, 258

Keras, 625

key functions, 141

key-value pairs, 222, 228

KeyboardInterrupt, 191, 198, 209

KeyError, 195, 209

keyword arguments, 128–129

keyword-only parameters, 132–133

keyword variadic parameters, 131

Kivy GUI toolkit, 621

Kneusel, Ronald T., 626

**kwargs parameter, 131–132, 398

__kwdefaults__ attribute, 645

L

lambdas, 119, 138–141, 145

language typing, 44, 98–99

languages

interpreted vs. assembled, 5

static vs. dynamic typing, 44, 98–99

LanguageTool API, 579, 588–589

lazy evaluation, 257–258, 270, 271–272, 671

LBYL (Look Before You Leap)

checking for conditions, 188, 224, 408–410

philosophy, 187

__le__() method, 173, 640

leading zeros flag, 58

left shift («) operator, 47, 345

LEGB (scope resolution) acronym, 105

len() function, 237, 254

__len__() method, 254, 358, 639

__length_hint__() method, 639

less than, 49, 172–173

LICENSE file, 74, 518, 519–520, 521

LiClipse, 36

lightning talks, 634

line limits, 28

line separators, 307

link_to() (path module) method, 326

linters, 29, 31

Linux

build dependencies, 15–16

and packaging, 537, 539–540

Python and pip installer, 15

Liskov Substitution Principle, 383

list comprehensions, 110, 277–278

lists

about, 218–219

mutability, 107–108

syntax, 65

literal patterns, 68

literals, string, 43, 53–55

little-endian byte order, 342–343

livelocks, 493–494

load() (json module) function, 331

__loader__ attribute, 644

loader objects, 90, 91

loads() (json module) function, 331

local scope, 100, 101, 104–105

locals() function, 429

Lock object, 492–493

locks and locking, 487–488, 492–494. See also Global Interpreter Lock (GIL)

Logger objects, 549–550

logging

about, 195, 507–508, 548–549, 556

examples, 195–199, 549–555

filters, 555

for[[matters, 555–556

logfiles, 199

severity levels, 196, 549, 552

logging module

assigning severity levels, 552–554

configuring, 196, 199

objects, 549–551, 555–556

logical shift operations, 345

LogRecord objects, 549, 550, 553

long integers, 343

Look Before You Leap (LBYL). See LBYL (Look Before You Leap)

lookup chains, 437

LookupError class, 209

loops

cont[[rolling, 67

enumerating items in, 244

vs. generator expressions, 281–282

for loops, 67–68, 215–216, 242–244

mutating items in, 244–246

nested, 247–248

in programming guidelines, 121

while loops, 66, 214–215

loose coupling technique, 383–384

__lshift__() method, 174, 345, 642

__lt__() method, 172–173, 640

Lubarsky's Law of Cybernetic Entomology, 543

lxml library, 333

M

machine code assembly, 5–6

machine learning/training, 625–626

macOS

build dependencies, 15

Python and pip installer, 14

magic methods. See special methods

__main__ value, 85–86, 426

__main__.py file, 76, 86–87

manifest templates, 527–528

MANIFEST.in file, 518, 527–528

map iterable, 250–251

map() method, 491

mapping, 222

mapping patterns, 229–230

mappingproxy, 427–428

Marick, Brian, 609

Märies, Ionel Cristian, 517

marking, 598–600, 672

marshal module, 374

__match_args__ attribute, 179–180

match/case statements, 68–71

math module, 47–48

math operations and constants, 45–48, 221–222

__matmul__() method, 174, 640

Matplotlib, 624

matrix multiplication (@) operator, 47

max() function, 248

McA’Nulty, Pamela, 507

McCabe complexity, 31, 32

member variables. See instance attributes

MemoryError, 209, 258

memoryview class, 361–363

MessagePack serialization format, 376

meta hooks, 90

meta path finders, 90

metaclasses

creating custom, 406–408

creating with type(), 404–405

method resolution order

and base class order, 392–395

example, 388–392

methods. See also special methods

about, 64, 150

and functional programming, 180

inspecting, 426–428

types, 158–160

MicroPython, 627

min() function, 248

Minecraft .dat file, 373

__missing__() method, 639

mixins, 399–401

mkdir() (path module) method, 326

mocking inputs, 592, 597–598

__mod__() method, 174, 640

mode= argument, 297–299

modification in place, 106

__module__ attribute, 645, 646

module search paths, 89–91

module spec objects, 91

ModuleNotFoundError, 77, 91, 209

modules

about, 74–75

entry points, 85–86

frozen, 90

naming conventions, 75

special attributes on, 644–645

updating, 518

modulo (%) operator, 46, 47

monkeypatching (monkeypatch tool), 597, 604–605

__mro__ attribute, 388, 646

__mul__() method, 174, 640

multiline string literals, 55

multiple inheritance

and base class order, 392–395

cont[[rolling resolution, 395–398

and metaclasses, 407

method resolution order, 388–392

multiplication (*) operator, 46

multiprocessing. See also producer/consumer problem

about, 477, 498–499

with Collatz game example, 500–501

logging with, 507–508

and pickle, 499–500

multiprocessing module, 498, 503, 505, 508

multisets, 224

multitasking, 458, 459, 478

multithreading, 478

mutable objects

about, 117

binding to, 109–114

data types, 106–107, 121

and default values, 126–127

mutating

avoiding, 110–111

defined, 117

effects of, 104, 106–107

in loops, 244–246

Muthukadan, Baiju, 602

Mypy, 33, 145

N

__name__ attribute, 85–86, 426, 645, 646

name mangling, 156–157, 674

named tuples (namedtuple), 217–218

NameError, 101, 209

names

about, 96, 99, 117

global scope, 102–104

local scope, 100, 101

namespace packages, 75, 676

namespaces, 78–79

naming conventions

for attribute scope, 156–157

class names, 656

constants, 44–45

packages and modules, 75

and Systems Hungarian Notation, 115–116

unit tests, 588

nan (invalid number) constant, 45, 47, 48

__ne__() (not equals) method, 172, 640

__neg__() (negative sign) method, 175, 641

negative binary notation, 343, 344–345, 350–351

negative numbers, 58, 175, 341

nesting

functions, 134–135

generator expressions, 276–277

loops vs. alternatives, 247–248, 272–273

and scope, 104–105

statements, 41

NetCDF (Network Common Data Form) serialization format, 376

neural networks, 625

__new__() method, 152–153, 406, 643, 644

newline (\n), 55, 56, 294, 307

next() function, 240–241

__next__() method, 238–241, 254–255, 259–260, 261, 638

non-data descriptors, 437

None (null) value, 50–51, 127

NoneType type, 675

nonlocal keyword, 105

nonpublic attributes, 156

nose2 module, 578

not equals, 49, 172

not keyword, 51–52, 237

notebook documents (Jupyter), 623

NotImplemented, 197

NotImplementedError, 197

Nuitka transpiler, 5, 537

null termination, 354

NullHandler, 551

Numba, 625

number systems

binary, 338

hexadecimal, 338–340

integers, 340–341

octal, 340

two's complement, 341

number types, 45–46

numbers module, 411

O

-O (optimize) flag, 556

object-oriented programming, 120, 149–151, 180

objects. See also mutable objects

about, 150

callable, 131–132

creating, 63–64

inheritance, 151

slicing on, 235

oct() function, 341

octal numbers, 340

ODF (Open Document Format) file format, 334

odfpy library, 334

offset keyword, 371

omission project example

directory structure, 75–76

entry point example, 88–89

importing example, 80–81, 82–85

setup, 74

one's complement (~), 47

Oolite (game), 373

open() function, 295–296

Open-Closed Principle, 382–383

operators, 46–47

optimize (-O) flag, 556

or keyword, 51–52

__or__() method, 174, 345, 642

or patterns, 69

ordered items, 217

OrderedDict, 224

os module, 315, 328

OSError, 209

os.system() function, 456

out-of-place testing, 580

OverflowError, 210

@overload decorator, 451

overloaded functions, 129–130

overwrite (\r), 294, 307

P

pack() (struct module) method, 352, 353–355

__package__ attribute, 644

package manager. See pip

packages. See also imports; uploads

about, 18–19, 74–75

contributing to, 628–629

editable, 531

entry points, 86–87

finding, 23

including files and additional, 523–524, 525

installing, 21–22, 531, 533

naming conventions, 75

provisional, 620

removing, 22–23

upgrading, 22

virtual environment access, 20, 21

packaging

artifacts build, 531

distribution options, 515–517

for end user distribution, 534–540

files and structure, 518–530

planning, 514–515, 517–518

publishing on pip, 532–534

and relative paths, 323–325

resources on, 514

packaging gradient, 516, 535

packaging tools, 534. See also setuptools library

padding, 354–355, 360–361

Paige, Jeremiah, 519

Pandas, 624

parallelism

about, 477, 497–498

vs. asynchrony, 459

vs. concurrency, 478

with multiprocessing, 498–501

parameters

about, 123, 676–677

and assignment, 107–109

optional vs. required, 126

positional and keyword, 132–134

type hints, 146–147

parametrization, 592, 594–596, 605

parent directory (..), 84, 318, 322

parentheses () operator, 46, 217

parents (path module) property, 317

partial() (functools module) function, 491

parts() (PurePath module) method, 317

Pascal strings, 354

pass keyword, 42

passing functions, 140–141

passing messages technique, 487, 495–496

patches, 631

__path__ attribute, 74, 91, 644

path-based finder, 90

path entry finders (path entries), 90–91

pathlib module

about, 315

classes, 315–316

operations, 320–323, 325–328

and path parts, 316–320

paths

about, 314

absolute, 316–320

modules, 315

objects, 315–316

relative, 322–325

patterns. See also anti-patterns

glob, 527

singleton, 407–408

structural matching, 68–71, 177–180, 228–230

virtual machine design, 373

pdb. See Python Debugger (pdb)

PendingDeprecationWarning, 545

PEP 8 (style guide), 27–29, 33–34, 75

PEP 20 (The Zen of Python), 8–9

PEPs (Python Enhancement Proposals), 9, 630

performance

benchmarking, 611, 612–613

and concurrency, 458

exception handling, 187–189, 223–224

perceived responsiveness, 463–464

profiling, 577, 613–617

program factors, 4–5

and programming paradigms, 121

permutations() (itertools module) function, 252

Peters, Tim, 8, 10, 404, 407

PEX (Python Executable), 535

pi constant, 47

pickle module, 374–375, 499–500

Pike, Rob, 478

pinning, 528

pip

about, 21

pip freeze command, 529

pip install command, 21–22, 23, 528–529

pip uninstall command, 22

pip-tools, 27

Pipenv tool, 27

Pirnat, Mike, 190

pkg_resources module, 325

place values, 339

plaintext files. See files

platform wheels, 516

.plist (property list) serialization format, 375

Poetry, 27, 534

polymorphism, 384

pop() method, 218, 221

popleft() method, 219–220

__pos__() method, 175, 641

positional arguments, 128–129

positional-only parameters, 133–134

POSIX file paths, 314, 319–320

PosixPath initializer, 320

__pow__() method, 174, 640

PowerShell, 19

pprint (pretty print) module, 427

precision flag, 58

__prepare__() method, 406, 644

Preston-Werner, Tom, 334

Price, Will, 607

priming, 678

print() function, 40, 290–294, 306–307

procedural programming, 120

process objects, 498

ProcessPoolExecutor, 498, 500

producer/consumer problem

about, 501–502

Collatz program implementation, 502–507

product() (itertools module) function, 248, 252

profile module, 613–617

profiling, 577, 611

program entry points, 88–89

programming

fields of study, 620–627

motivation, 11, 456, 635

paradigms, 120–122, 149

projects. See also packaging

licensing, 519–520, 521

metadata, 519, 522

naming, 520–521

setup, 74, 77

versions, 521

virtual environments for, 19

working with, 6

prompt keyword, 294–295

properties

about, 160, 679

application of, 166–167

defining with decorators, 164–166

instance methods, 161–164

property() function, 163, 164–165, 166

property list (.plist) serialization format, 375

Protocol Buffers (Google), 377

provisional packages, 620

prune directive, 527

.pth file extension, 89

public attributes, 156

pure paths, 315–316

PurePath objects, 316

PureWindowsPath initializer, 320

.py files, 18

py2app, 536

py2exe tool, 5

PyAutoGUI, 602

.pyc files, 6, 91

PyCharm, 35, 145

pycodestyle, 31

PyDev plug-in, 36

pydoc, 540

py.exe command, 17

PyFlakes, 31

PyGame, 622

PyGObject, 621

PyInstaller, 6, 535, 536

PyLadies, 633

Pylint, 29–31

pylintrc file, 31

Pyodide, 623

PyOxidizer, 536

PyPI. See Python Package Index (PyPI)

pyproject.toml file, 518, 519, 529–530

PyPy, 627

PyRTF library, 334

pytest

about, 578

exceptions testing, 585–586

executing tests in, 584

object naming with, 583–584

pytest-qt, 602

Python

and C language, 352

contributing to, 630–631

developing for, 628–631

development of, 3–4

documentation, 9

governance, 9

implementations, 627–628

installing, 14–17

principles and practices, 5–6, 7–9, 10–11, 121

reporting bugs and security flaws, 574

running, 17–18

versions, 6–7, 17

Python Code of Conduct, 10

Python community, 10, 631–635

Python Debugger (pdb)

about, 560–561

buggy code example, 561–562

commands reference, 647–649

example program, 561–562

inspecting and checking, 567–569

moving through execution stack, 565–566

postmortem use, 569–570

starting, 562–563

stepping through code, 563–565

Python interpreter

about, 5, 6, 102

specifying path to, 24–25

Python Package Index (PyPI), 23, 516, 522, 629

Python Packaging Authority (PyPA), 515, 630

Python Software Foundation (PSF), 9, 634–635

python3 command, 17

pythonfuzz tool, 605

Pythonic code, 7

Python.NET, 628

PYTHONPATH variable, 89

PyTorch, 625

PyYAML library, 334

Q

Qt GUI framework, 602, 621

qualified vs. unqualified names, 70, 79, 666, 680

quality assurance (QA), 577

__qualname__ attribute, 645, 646

queues (queue module), 495–496, 503, 505, 508

quotation marks, 43, 54–55, 57

R

r (raw string) keyword, 55–56

race conditions, 487, 488–489, 491–492

__radd__() method, 174, 641

radians() (math module) function, 48

radint() (random module) function, 122

raise keyword, 192–193, 200

__rand__() method, 174, 642

random module, 122

range() iterable, 67, 249

raw bytes literals, 347

raw strings, 55–56

raw_input() function, 295

__rdivmod__() method, 174, 641

read() method, 296, 299–300, 307

readable() method, 299

readline() method, 300–301, 307

readlines() method, 301, 307

README file, 74, 518, 519, 521

read-only descriptors, 437

read_text() (path module) method, 325

rebinding, 117. See also binding

recursion, 121, 124–125, 134–135, 136–137

recursion depth, 124–125

RecursionError, 125, 210

reentrancy, 488, 502

reference-counting garbage collector, 100–101

references, 109–114, 117

register(), 451–452

relative imports, 83–85

relative paths, 322–325

release() method, 363, 493

remove() method, 221

rename() (path module) method, 326

repeat() (itertools module) function, 258, 507

replace() (path module) method, 71, 326, 327–328

repositories (project), 74, 75–76

repr() function, 61

__repr__() method, 168–169, 638

requests module, 579, 580

requirements.txt file, 22, 518, 528–529

resolve() (Path module) method, 323

ResourceWarning, 545

reStructuredText (reST), 540–541

result() method, 486

return statement, 152

reversed() function, 249

__reversed__() method, 418, 639

__rfloordiv__() method, 174, 641

right shift (») operator, 47, 345

RLock object, 494

__rlshift__() method, 174, 642

__rmatmul__() method, 174, 641

rmdir() (path module) method, 326

__rmod__() method, 174, 641

__rmul__() method, 174, 641

RobotFramework, 579

root (in path names), 318, 319

__ror__() method, 174, 642

round() function, 48

__round__() method, 171, 638

__rpow__() method, 174, 641

RPython, 627

__rrshift__() method, 174, 643

__rshift__() method, 174, 345, 642

__rsub__() method, 173, 174, 641

RTF (Rich Text Format) file format, 334–335

RTFMaker library, 334

__rtruediv__() method, 174, 641

run() (asyncio module) function, 468

RuntimeError, 210

RuntimeWarning, 545

run_until_complete() function, 468

RustPython, 628

__rxor__() method, 174, 642

S

sandboxing, 537

sched module, 508

scientific notation, 45

Scikit-learn library, 625

SciPy library, 624

scope. See also global scope; local scope

about, 100, 117, 681

enclosing, 105

naming conventions, 156–157

resolution order, 105

screaming snake case, 44–45

scripting (field of study), 627

sdist (source distribution), 516, 531

Seaborn, 624

SecretAgent class example

attributes, 155

creating, 151–152, 153, 154

methods, 158–160

properties, 162–166

security

and code analysis, 571–574

of data, 373–374

as field of study, 626

seek() method, 298, 302–303, 371

seekable() method, 299

segmentation faults, 570–571

Seitz, Justin, 626

Selenium, 602

self parameter, 64, 152, 682

Sempf, Bill, 185

send() method, 283–285

sep= keyword, 294

sequence patterns, 228–229

sequences, 70, 351

serialization

and deserialization, 328–332

formats, 375–377

techniques, 373–375

set comprehensions, 278

set mathematics, 221–222

__set__() method, 437, 639

setattr() function, 431–433

__setattr__() method, 431–433, 643

__setitem__() method, 231, 235, 639

setlevel() method, 553

__set_name__() method, 437, 443, 639

setrecursionlimit() (sys module) function, 125

sets, 220–222

__setstate__() method, 499

setters, 150, 161–163

setup() (setuptools module) function, 526

setup.cfg file, 518, 519, 520–526

setup.py file, 518, 519

setuptools library, 518, 525, 526, 529

setuptools-scm, 521

severity levels, 196, 549, 552–554

shadowing

functions, 79–80, 81–82

names, 102

shallow copy, 111–113, 117

shared state technique, 487–488

shebang (#!) command, 24–25

shelve module, 374

shutdown() function, 485

side effects, 108, 120

sign bit, 345

sign flags, 58

signal module, 503

signed= keyword, 351

simple statements, 40

Simplified Wrapper and Interface Generator (SWIG), 630

single-dispatch generic functions, 449–452

@singledispatch decorator, 449–450

@singledispatchmethod decorator, 449–450

Single-Responsibility Principle, 181, 196, 382

size= keyword, 300, 301

size_t(n) data type, 355

Skulpt, 623

sleep() function, 466

slice() method, 235

slice notation, 231–236

slicing bytes objects, 361–363

slots

about, 444–445

for immutable classes, 447–449

using, 445–446

__slots__ attribute, 444–446, 646

SMTPHandler, 551

snake case, 683

Snakeviz, 616–617

Snapcraft, 538

SocketHandler objects, 551

SOLID principles, 382–384

sorted() function, 108, 141, 243–244, 249

source distribution (sdist), 516, 531

spaces vs. tabs, 28–29, 41–42

__spec__ attribute, 645

special attributes, 426, 644–646, 654

special methods

about, 167

binary operator support, 173–174

comparisons, 171–173

conversions, 168–171

list by category, 638–644

making instances callable, 175–176

NotImplemented exceptions, 197

unary operator support, 174–175

Sphinx, 540–541

sprints, 634

Spyder, 36

src/ directory, 517–518, 580

ssize_t(n) data type, 355

Stackless Python, 627

standard error stream, 290–291, 297

standard input stream, 297, 469

standard output stream, 290, 297

starmap() (itertools module) function, 252

starred expressions, 226–227

starvation, 494

stateful closures, 137–138

statements, 40–42, 53

states, 120, 180, 181, 190, 684

static analyzers, 29–33, 571

static classes, 181, 657

static methods, 159–160

static vs. dynamic typing, 6, 44, 98–99

@staticmethod decorator, 160

stderr (standard error) stream, 290–291, 297

stdin (standard input) stream, 297, 469

stdout (standard output) stream, 290, 297

stem (in path names), 318, 319

StopAsyncIteration, 474

StopIteration, 200, 240, 261, 264

str() function, 56, 61

__str__() method, 169–170, 638

StreamHandler objects, 550, 551

streams. See also files

as iterators, 301–302

position in, 302–303

standard, 290–291, 297

types, 295

strings. See also docstrings

concatenations, 62

conversions, 61–62

formatted strings (f-strings), 56–60

immutability, 106

and printing, 292–294

raw strings, 55–56

string literals, 53–55

template strings, 60–61

strip() method, 71

strongly typed languages, 44

struct module, 352–357

about, 352–353

creating Struct objects, 356–357

packing to binary, 353–355

unpacking to Python values, 355–356

structural pattern matching, 68–71, 177–180, 228–230

stub classes, 385

style guidelines, 27–29, 31, 33–34, 75

__sub__() method, 173, 174, 640

__subclasscheck__() method, 418, 644

__subclasshook__() method, 644

Sublime Text, 35–36

subpackages, 75

subprocess module, 456, 508

subprocesses

in producer/consumer problem, 503–504, 506–507

and speed considerations, 500–501

subscriptable collections, 231

subscripts. See indices (subscripts)

subset (<) operator, 221

subtraction (-) operator, 46

sudo pip warning, 23

suffixes (in path names), 318, 319–320

suffixes (path module) property, 317

suites, 41

sum() function, 161, 249

super() function, 396–398

superclass linearization, 389–392

superset (>) operator, 221

Svetlov, Andrew, 468

Sweigart, Al, 622, 627

symlink_to() (path module) method, 326

symmetric difference (^) set operator, 221

SyntaxError, 210

SyntaxWarning, 545

sys module, 291

SystemError, 210

SystemExit, 210

Systems Hungarian Notation, 115–116

T

tab (\t), 293–294

TabError, 210

tabs vs. spaces, 28–29, 41–42

takewhile() (itertools module) function, 252

tan() (math module) function, 48

.tar.gz files, 516, 531

tasks, 466–468

tau constant, 47

teardown tasks, 586, 686

tell() method, 302

template strings, 60–61

TensorFlow library, 625

ternary expressions, 275

test-driven development (TDD), 578

Test PyPI, 532

testing. See also pytest; textproof project example

approaches, 185–186, 577–578

code coverage evaluation, 607–609

edge cases, 605

and external resources, 592

with fixtures, 586–588

flaky tests, 591

frameworks, 34, 578–579

GUI and web-based applications, 601–602

with marking, 598

with mocked inputs, 597–598

of packages, 530–531, 532, 610–611

with parametrization, 594, 595, 605

and project structure, 580

unit testing, 583–584

text-based serialization, 373–374

text streams, 295, 298

TextIOWrapper object, 296

textproof project example

API communication, 588–590

capturing output, 600–601

command-line interface, 606–607

connecting API, 602–604

exception tests, 585–586

fixtures, 586–588, 595–596

initial code, 582

input mocking, 597–598

integration testing example, 605

marking, 598–600

project files, 580–582

pytest installation, 584

skipped test examples, 591–592

Typo initializer, 592–595

unit test examples, 583–584

_thread module, 479, 508

thread of execution, 459, 478

threading

about, 459, 477

basic, 478–481

daemonic threads, 782–483

futures and executors, 483–485

and locks, 492–494

race conditions, 487, 488–492

safety, 486–488

timeouts, 481–482, 486

threading module, 478–479, 508

ThreadPoolExecutor object, 484, 491–492

three-dot (…) prompt, 18

throw() method, 266–268

Timecard packaging example, 514, 520–523, 525–526, 532–534

timeit module, 612–613

timeout= keyword, 482, 486

TimeoutError, 486

timeouts, 481–482, 486, 506

Tkinter GUI framework, 621

to_bytes() method, 349–351

TOML (TOM's Obvious Minimal Language) file format, 334

tool configurations, 530

TOOWTDI (There's Only One Way To Do It), 7, 10

top-level packages, 75

touch() (path module) method, 326

tox tool, 578, 610–11

trace module, 607

tracebacks, 185–186, 186–187

tracemalloc, 617

trailing commas, 126, 217, 226

training (machine learning), 625

transpilers, 5

Trio library, 460, 466, 468

True and False values, 51, 237–238, 345

__truediv__() method, 174, 640

__trunc__() method, 171, 638

truncate() method, 305

try clauses, 64–65, 187–188, 189

tuples

in collections, 216–218

concatenating, 62

immutability, 106

syntax, 65–66

unpacking, 123

Turing completeness, 4

twine, 532

Twisted library, 460

2to3 tool, 7

two's complement, 341, 350–351

type, 117. See also data type

type aliases, 146

type() function, 99–100, 404–405

type hints, 145–147

type (number) flag, 59

TypeError, 65, 134, 152, 198, 210

typing module, 145–147

U

unary operators, 46, 47, 174–175

UnboundLocalError, 210

unbuffered mode, 292

undefined behavior, 570–571

underscore (_)

as name, 226, 227

as wildcard, 68

UnicodeError, 190

UnicodeWarning, 545

union (|) set operator, 221

unittest module, 578

UNIX

file paths, 314–315, 319–320

machine code assembly, 5

Python installer, 15–17

unlink() (path module) method, 326

unordered collections, 220

unpack() (struct module) method, 355–356

unpacking

from bytes objects to Python values, 355–356

deques, 225–226

dictionaries, 227–228

with starred expressions, 226–227

tuples, 123, 126

UnsupportedOperation, 299

uploads

to PyPI, 534

to Test PyPI, 532–533

user groups, 633

UserWarning, 545

UTF-8 encoding, 25–26, 349

V

validation vs. assertion, 558–559

ValueError, 65`, 115, 190, 198, 210

values

about, 96, 99, 117

coercion and conversion, 114–115

garbage collection of, 100–101

and identity, 97–98

local vs. global references, 101

mutating, 106–107

values() method, 228

van Rossum, Guido, 3, 4, 8, 9, 10

variable annotations, 145–146

variables. See also names; values

about, 96, 117

declaring, 44–45

in f-strings, 56–57

scope, 100, 102–104

variadic arguments, 130–132

vars() function, 428–429

Vaughan, Lee, 625, 627

venv command or directory, 19

version control systems (VCS), 19, 23–24, 74

versions, 521, 525

Viafore, Patrick, 407

Vim, 34–35

virtual environments

activating, 20

creating, 19

leaving, 20–21

module search paths in, 89–90

using without activating, 26

and VCS repositories, 23–24

virtual machine design patterns, 373

virtual machines, 6

virtual subclasses, 418–422

virtualenv command, 19

Visual Studio Code, 35

VOC transpiler, 5

void

W

walrus (:=) operator, 52–53, 369

Ward framework, 579

warning categories, 545

warning filters, 546–548

warnings

converting to exceptions, 548

creating, 544–546

weak references, 106, 117, 446

__weakref__ attribute, 446, 646

web development, 622–623

wheel artifacts (.whl), 516, 531

whence keyword, 302, 371

while loops, 66, 214–215, 245–246

whitespace, 41–42

wildcards, 68, 229–230, 527

Windows

machine code assembly, 5

paths, 318–319

Python installer, 14

with statement, 297, 307–309

with_name() (path module) method, 327

word size, 355

worker threads

creating, 491–492

and queues, 495–496

workshops, 634

wrapper modules, 629

wrappers, 144

wraps (functools module) function, 144

writable() method, 299

write() method, 304–305, 307

writelines() method, 305–306, 307

write_text() (path module) method, 325

X

XML file format, 333

__xor__() method, 174, 345, 642

Y

YAML file format, 333–334

yield from statement, 268–270

yield statement, 259–260, 283, 285

Z

Zen of Python, The, 8–9, 10, 279–280

ZeroDivisionError, 198, 210

zip iterable, 251

Fair Use Sources

Python: Python Variables, Python Data Types, Python Control Structures, Python Loops, Python Functions, Python Modules, Python Packages, Python File Handling, Python Errors and Exceptions, Python Classes and Objects, Python Inheritance, Python Polymorphism, Python Encapsulation, Python Abstraction, Python Lists, Python Dictionaries, Python Tuples, Python Sets, Python String Manipulation, Python Regular Expressions, Python Comprehensions, Python Lambda Functions, Python Map, Filter, and Reduce, Python Decorators, Python Generators, Python Context Managers, Python Concurrency with Threads, Python Asynchronous Programming, Python Multiprocessing, Python Networking, Python Database Interaction, Python Debugging, Python Testing and Unit Testing, Python Virtual Environments, Python Package Management, Python Data Analysis, Python Data Visualization, Python Web Scraping, Python Web Development with Flask/Django, Python API Interaction, Python GUI Programming, Python Game Development, Python Security and Cryptography, Python Blockchain Programming, Python Machine Learning, Python Deep Learning, Python Natural Language Processing, Python Computer Vision, Python Robotics, Python Scientific Computing, Python Data Engineering, Python Cloud Computing, Python DevOps Tools, Python Performance Optimization, Python Design Patterns, Python Type Hints, Python Version Control with Git, Python Documentation, Python Internationalization and Localization, Python Accessibility, Python Configurations and Environments, Python Continuous Integration/Continuous Deployment, Python Algorithm Design, Python Problem Solving, Python Code Readability, Python Software Architecture, Python Refactoring, Python Integration with Other Languages, Python Microservices Architecture, Python Serverless Computing, Python Big Data Analysis, Python Internet of Things (IoT), Python Geospatial Analysis, Python Quantum Computing, Python Bioinformatics, Python Ethical Hacking, Python Artificial Intelligence, Python Augmented Reality and Virtual Reality, Python Blockchain Applications, Python Chatbots, Python Voice Assistants, Python Edge Computing, Python Graph Algorithms, Python Social Network Analysis, Python Time Series Analysis, Python Image Processing, Python Audio Processing, Python Video Processing, Python 3D Programming, Python Parallel Computing, Python Event-Driven Programming, Python Reactive Programming.

Variables, Data Types, Control Structures, Loops, Functions, Modules, Packages, File Handling, Errors and Exceptions, Classes and Objects, Inheritance, Polymorphism, Encapsulation, Abstraction, Lists, Dictionaries, Tuples, Sets, String Manipulation, Regular Expressions, Comprehensions, Lambda Functions, Map, Filter, and Reduce, Decorators, Generators, Context Managers, Concurrency with Threads, Asynchronous Programming, Multiprocessing, Networking, Database Interaction, Debugging, Testing and Unit Testing, Virtual Environments, Package Management, Data Analysis, Data Visualization, Web Scraping, Web Development with Flask/Django, API Interaction, GUI Programming, Game Development, Security and Cryptography, Blockchain Programming, Machine Learning, Deep Learning, Natural Language Processing, Computer Vision, Robotics, Scientific Computing, Data Engineering, Cloud Computing, DevOps Tools, Performance Optimization, Design Patterns, Type Hints, Version Control with Git, Documentation, Internationalization and Localization, Accessibility, Configurations and Environments, Continuous Integration/Continuous Deployment, Algorithm Design, Problem Solving, Code Readability, Software Architecture, Refactoring, Integration with Other Languages, Microservices Architecture, Serverless Computing, Big Data Analysis, Internet of Things (IoT), Geospatial Analysis, Quantum Computing, Bioinformatics, Ethical Hacking, Artificial Intelligence, Augmented Reality and Virtual Reality, Blockchain Applications, Chatbots, Voice Assistants, Edge Computing, Graph Algorithms, Social Network Analysis, Time Series Analysis, Image Processing, Audio Processing, Video Processing, 3D Programming, Parallel Computing, Event-Driven Programming, Reactive Programming.


Python Glossary, Python Fundamentals, Python Inventor: Python Language Designer: Guido van Rossum on 20 February 1991; PEPs, Python Scripting, Python Keywords, Python Built-In Data Types, Python Data Structures - Python Algorithms, Python Syntax, Python OOP - Python Design Patterns, Python Module Index, pymotw.com, Python Package Manager (pip-PyPI), Python Virtualization (Conda, Miniconda, Virtualenv, Pipenv, Poetry), Python Interpreter, CPython, Python REPL, Python IDEs (PyCharm, Jupyter Notebook), Python Development Tools, Python Linter, Pythonista-Python User, Python Uses, List of Python Software, Python Popularity, Python Compiler, Python Transpiler, Python DevOps - Python SRE, Python Data Science - Python DataOps, Python Machine Learning, Python Deep Learning, Functional Python, Python Concurrency - Python GIL - Python Async (Asyncio), Python Standard Library, Python Testing (Pytest), Python Libraries (Flask), Python Frameworks (Django), Python History, Python Bibliography, Manning Python Series, Python Official Glossary - Python Glossary, Python Topics, Python Courses, Python Research, Python GitHub, Written in Python, Python Awesome List, Python Versions. (navbar_python - see also navbar_python_libaries, navbar_python_standard_library, navbar_python_virtual_environments, navbar_numpy, navbar_datascience)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


dead_simple_python_index.txt · Last modified: 2024/04/28 03:51 by 127.0.0.1