Showing posts with label Manning. Show all posts

Understanding, analyzing, and generating text with Python

Hobson Lane, Cole Howard, Hannes Max Hapke

brief contents

PART 1 WORDY MACHINES

Packets of thought (NLP overview) 
Build your vocabulary (word tokenization)
Math with words (TF-IDF vectors)
Finding meaning in word counts (semantic analysis) 

PART 2 DEEPER LEARNING (NEURAL NETWORKS)

Baby steps with neural networks (perceptrons and backpropagation)
Reasoning with word vectors (Word2vec)
Getting words in order with convolutional neural networks (CNNs)
Loopy (recurrent) neural networks (RNNs)
Improving retention with long short-term memory networks
Sequence-to-sequence models and attention 

PART 3 GETTING REAL (REAL-WORLD NLP CHALLENGES)

Information extraction (named entity extraction and question answering)
Getting chatty (dialog engines) 
Scaling up (optimization, parallelization, and batch processing)
e-books shop

e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 3.00
 Pages
 545 p
 File Size 
 9,938 KB
 File Type
 PDF format
 ISBN
 9781617294631
 Copyright©   
 2019 by Manning Publications Co 

about the author
HOBSON LANE has 20 years of experience building autonomous
systems that make important decisions on behalf of humans. At
Talentpair Hobson taught machines to read and understand
resumes with less bias than most recruiters. At Aira he helped
build their first chatbot to interpret the visual world for those who
are blind. Hobson is passionate about openness and prosocial AI.
He’s an active contributor to open source projects such as Keras,
scikit-learn, PyBrain, PUGNLP, and ChatterBot. He’s currently
pursuing open science research and education projects for Total Good including
building an open source cognitive assistant. He has published papers and presented
talks at AIAA, PyCon, PAIS, and IEEE and has been awarded several patents in Robotics and Automation.

HANNES MAX HAPKE is an electrical engineer turned machine
learning engineer. He became fascinated with neural networks in
high school while investigating ways to compute neural networks
on micro-controllers. Later in college, he applied concepts of
neural nets to control renewable energy power plants effectively.
Hannes loves to automate software development and machine
learning pipelines. He co-authored deep learning models and
machine learning pipelines for recruiting, energy, and healthcare
applications. Hannes presented on machine learning at various conferences including
OSCON, Open Source Bridge, and Hack University.

COLE HOWARD is a machine learning engineer, NLP practitioner,
and writer. A lifelong hunter of patterns, he found his true home in
the world of artificial neural networks. He has developed large-scale
e-commerce recommendation engines and state-of-the-art neural
nets for hyperdimensional machine intelligence systems (deep
learning neural nets), which perform at the top of the leader board
for the Kaggle competitions. He has presented talks on Convolutional
Neural Nets, Recurrent Neural Nets, and their roles in natural language processing
at the Open Source Bridge Conference and Hack University.

about this book
Natural Language Processing in Action is a practical guide to processing and generating
natural language text in the real world. In this book we provide you with all the tools and
techniques you need to build the backend NLP systems to support a virtual assistant
(chatbot), spam filter, forum moderator, sentiment analyzer, knowledge base builder,
natural language text miner, or nearly any other NLP application you can imagine.

Natural Language Processing in Action is aimed at intermediate to advanced Python
developers. Readers already capable of designing and building complex systems will
also find most of this book useful, since it provides numerous best-practice examples
and insight into the capabilities of state-of-the art NLP algorithms. While knowledge
of object-oriented Python development may help you build better systems, it’s not
required to use what you learn in this book.

For special topics, we provide sufficient background material and cite resources
(both text and online) for those who want to gain an in-depth understanding.

Table of Contents
foreword xiii
preface xv
acknowledgments xxi
about this book xxiv
about the authors xxvii
about the cover illustration xxix
PART 1 WORDY MACHINES ........................................... 1
1 Packets of thought (NLP overview) 3
1.1 Natural language vs. programming language 4
1.2 The magic 4
Machines that converse 5 ■ The math 6
1.3 Practical applications 8
1.4 Language through a computer’s “eyes” 9
The language of locks 10 ■ Regular expressions 11
A simple chatbot 12 ■ Another way 16
1.5 A brief overflight of hyperspace 19
1.6 Word order and grammar 21
1.7 A chatbot natural language pipeline 22
1.8 Processing in depth 25
1.9 Natural language IQ 27
2 Build your vocabulary (word tokenization) 30
2.1 Challenges (a preview of stemming) 32
2.2 Building your vocabulary with a tokenizer 33
Dot product 41 ■ Measuring bag-of-words overlap 42
A token improvement 43 ■ Extending your vocabulary with
n-grams 48 ■ Normalizing your vocabulary 54
2.3 Sentiment 62
VADER—A rule-based sentiment analyzer 64 ■ Naive Bayes 65
3 Math with words (TF-IDF vectors) 70
3.1 Bag of words 71
3.2 Vectorizing 76
Vector spaces 79
3.3 Zipf’s Law 83
3.4 Topic modeling 86
Return of Zipf 89 ■ Relevance ranking 90 ■ Tools 93
Alternatives 93 ■ Okapi BM25 95 ■ What’s next 95
4 Finding meaning in word counts (semantic analysis) 97
4.1 From word counts to topic scores 98
TF-IDF vectors and lemmatization 99 ■ Topic vectors 99
Thought experiment 101 ■ An algorithm for scoring topics 105
An LDA classifier 107
4.2 Latent semantic analysis 111
Your thought experiment made real 113
4.3 Singular value decomposition 116
U—left singular vectors 118 ■ S—singular values 119
VT—right singular vectors 120 ■ SVD matrix orientation 120
Truncating the topics 121
4.4 Principal component analysis 123
PCA on 3D vectors 125 ■ Stop horsing around and get back to
NLP 126 ■ Using PCA for SMS message semantic analysis 128
Using truncated SVD for SMS message semantic analysis 130
How well does LSA work for spam classification? 131
4.5 Latent Dirichlet allocation (LDiA) 134
The LDiA idea 135 ■ LDiA topic model for SMS messages 137
LDiA + LDA = spam classifier 140 ■ A fairer comparison:
32 LDiA topics 142
4.6 Distance and similarity 143
4.7 Steering with feedback 146
Linear discriminant analysis 147
4.8 Topic vector power 148
Semantic search 150 ■ Improvements 152
PART 2 DEEPER LEARNING (NEURAL NETWORKS) ...... 153
5 Baby steps with neural networks (perceptrons and
backpropagation) 155
5.1 Neural networks, the ingredient list 156
Perceptron 157 ■ A numerical perceptron 157 ■ Detour
through bias 158 ■ Let’s go skiing—the error surface 172
Off the chair lift, onto the slope 173 ■ Let’s shake things up a
bit 174 ■ Keras: neural networks in Python 175 ■ Onward
and deepward 179 ■ Normalization: input with style 179
6 Reasoning with word vectors (Word2vec) 181
6.1 Semantic queries and analogies 182
Analogy questions 183
6.2 Word vectors 184
Vector-oriented reasoning 187 ■ How to compute Word2vec
representations 191 ■ How to use the gensim.word2vec
module 200 ■ How to generate your own word vector
representations 202 ■ Word2vec vs. GloVe (Global Vectors) 205
fastText 205 ■ Word2vec vs. LSA 206 ■ Visualizing word
relationships 207 ■ Unnatural words 214 ■ Document
similarity with Doc2vec 215
7 Getting words in order with convolutional neural networks
(CNNs) 218
7.1 Learning meaning 220
7.2 Toolkit 221
7.3 Convolutional neural nets 222
Building blocks 223 ■ Step size (stride) 224 ■ Filter
composition 224 ■ Padding 226 ■ Learning 228
7.4 Narrow windows indeed 228
Implementation in Keras: prepping the data 230 ■ Convolutional
neural network architecture 235 ■ Pooling 236
Dropout 238 ■ The cherry on the sundae 239 ■ Let’s get to
learning (training) 241 ■ Using the model in a pipeline 243
Where do you go from here? 244
8 Loopy (recurrent) neural networks (RNNs) 247
8.1 Remembering with recurrent networks 250
Backpropagation through time 255 ■ When do we update
what? 257 ■ Recap 259 ■ There’s always a catch 259
Recurrent neural net with Keras 260
8.2 Putting things together 264
8.3 Let’s get to learning our past selves 266
8.4 Hyperparameters 267
8.5 Predicting 269
Statefulness 270 ■ Two-way street 271 ■ What is this thing? 272
9 Improving retention with long short-term memory networks 274
9.1 LSTM 275
Backpropagation through time 284 ■ Where does the rubber hit the
road? 287 ■ Dirty data 288 ■ Back to the dirty data 291
Words are hard. Letters are easier. 292 ■ My turn to chat 298
My turn to speak more clearly 300 ■ Learned how to say, but
not yet what 308 ■ Other kinds of memory 308 ■ Going deeper 309
10 Sequence-to-sequence models and attention 311
10.1 Encoder-decoder architecture 312
Decoding thought 313 ■ Look familiar? 315 ■ Sequence-tosequence
conversation 316 ■ LSTM review 317
10.2 Assembling a sequence-to-sequence pipeline 318
Preparing your dataset for the sequence-to-sequence training 318
Sequence-to-sequence model in Keras 320 ■ Sequence
encoder 320 ■ Thought decoder 322 ■ Assembling the
sequence-to-sequence network 323
10.3 Training the sequence-to-sequence network 324
Generate output sequences 325
10.4 Building a chatbot using sequence-to-sequence
networks 326
Preparing the corpus for your training 326 ■ Building your
character dictionary 327 ■ Generate one-hot encoded training
sets 328 ■ Train your sequence-to-sequence chatbot 329
Assemble the model for sequence generation 330 ■ Predicting a
sequence 330 ■ Generating a response 331 ■ Converse with
your chatbot 331
10.5 Enhancements 332
Reduce training complexity with bucketing 332 ■ Paying
attention 333
10.6 In the real world 334
PART 3 GETTING REAL (REAL-WORLD NLP
CHALLENGES) .............................................. 337
11 Information extraction (named entity extraction and question
answering) 339
11.1 Named entities and relations 339
A knowledge base 340 ■ Information extraction 343
11.2 Regular patterns 343
Regular expressions 344 ■ Information extraction as ML feature
extraction 345
11.3 Information worth extracting 346
Extracting GPS locations 347 ■ Extracting dates 347
11.4 Extracting relationships (relations) 352
Part-of-speech (POS) tagging 353 ■ Entity name normalization 357
Relation normalization and extraction 358 ■ Word patterns 358
Segmentation 359 ■ Why won’t split('.!?') work? 360
Sentence segmentation with regular expressions 361
11.5 In the real world 363
12 Getting chatty (dialog engines) 365
12.1 Language skill 366
Modern approaches 367 ■ A hybrid approach 373
12.2 Pattern-matching approach 373
A pattern-matching chatbot with AIML 375 ■ A network view of
pattern matching 381
12.3 Grounding 382
12.4 Retrieval (search) 384
The context challenge 384 ■ Example retrieval-based
chatbot 386 ■ A search-based chatbot 389
12.5 Generative models 391
Chat about NLPIA 392 ■ Pros and cons of each approach 394
12.6 Four-wheel drive 395
The Will to succeed 395
12.7 Design process 396
12.8 Trickery 399
Ask questions with predictable answers 399 ■ Be entertaining 399
When all else fails, search 400 ■ Being popular 400 ■ Be a
connector 400 ■ Getting emotional 400
12.9 In the real world 401
13 Scaling up (optimization, parallelization, and batch processing) 403
13.1 Too much of a good thing (data) 404
13.2 Optimizing NLP algorithms 404
Indexing 405 ■ Advanced indexing 406 ■ Advanced indexing
with Annoy 408 ■ Why use approximate indexes at all? 412
An indexing workaround: discretizing 413
13.3 Constant RAM algorithms 414
Gensim 414 ■ Graph computing 415
13.4 Parallelizing your NLP computations 416
Training NLP models on GPUs 416 ■ Renting vs. buying 417
GPU rental options 418 ■ Tensor processing units 419
13.5 Reducing the memory footprint during model training 419
13.6 Gaining model insights with TensorBoard 422
How to visualize word embeddings 423
appendix A Your NLP tools 427
appendix B Playful Python and regular expressions 434
appendix C Vectors and matrices (linear algebra fundamentals) 440
appendix D Machine learning tools and techniques 446
appendix E Setting up your AWS GPU 459
appendix F Locality sensitive hashing 473
resources 481
glossary 490
index 497


Bookscreen
e-books shop

about the cover illustration
The figure on the cover of Natural Language Processing in Action is captioned “Woman
from Kranjska Gora, Slovenia.” This illustration is taken from a recent reprint of
Balthasar Hacquet’s Images and Descriptions of Southwestern and Eastern Wends, Illyrians,
and Slavs, published by the Ethnographic Museum in Split, Croatia, in 2008. Hacquet
(1739–1815) was an Austrian physician and scientist who spent many years studying
the botany, geology, and ethnography of the Julian Alps, the mountain range that
stretches from northeastern Italy to Slovenia and that is named after Julius Caesar.
Hand drawn illustrations accompany the many scientific papers and books that Hacquet published.

The rich diversity of the drawings in Hacquet’s publications speaks vividly of the
uniqueness and individuality of the eastern Alpine regions just 200 years ago. This was
a time when the dress codes of two villages separated by a few miles identified people
uniquely as belonging to one or the other, and when members of a social class or
trade could be easily distinguished by what they were wearing. Dress codes have
changed since then and the diversity by region, so rich at the time, has faded away. It is
now often hard to tell the inhabitant of one continent from another, and today the
inhabitants of the picturesque towns and villages in the Slovenian Alps are not readily
distinguishable from the residents of other parts of Slovenia or the rest of Europe.

We at Manning celebrate the inventiveness, the initiative, and, yes, the fun of the
computer business with book covers based on the rich diversity of regional life of two
centuries ago‚ brought back to life by the pictures from this collection.

VERNON L. CEDER

FIRST EDITION BY DARYL K. HARMS & KENNETH M. McDONALD


e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 2.00
 Pages
 362 p
 File Size 
 2,910 KB
 File Type
 PDF format
 ISBN
 9781935182207
 Copyright©   
 2010 by Manning Publications Co 

About the Author
Second edition author Vern Ceder has been programming in various languages for
over 20 years and has been a Linux system administrator since 2000. He started using
Python for a variety of projects in 2001 and is director of technology at the Canterbury
School in Fort Wayne, Indiana, where he teaches Python to high school students and
teachers and gives talks to whomever will listen on Python and the benefits of teaching
programming in schools. An advocate for open software and open content, Vern is a
principal organizer of the Fort Wayne Linux Users Group.

About the cover illustration
The illustration on the cover of The Quick Python Book, Second Edition is taken from a
late 18th century edition of Sylvain Maréchal’s four-volume compendium of regional
dress customs published in France. Each illustration is finely drawn and colored by
hand. The rich variety of Maréchal’s collection reminds us vividly of how culturally
apart the world’s towns and regions were just 200 years ago. Isolated from each other,
people spoke different dialects and languages. In the streets or in the countryside, it
was easy to identify where they lived and what their trade or station in life was just by
what they were wearing.

Dress codes have changed since then and the diversity by region, so rich at the
time, has faded away. It is now hard to tell apart the inhabitants of different continents,
let alone different towns or regions. Perhaps we have traded cultural diversity
for a more varied personal life—certainly for a more varied and fast-paced technological life.

At a time when it is hard to tell one computer book from another, Manning celebrates
the inventiveness and initiative of the computer business with book covers
based on the rich diversity of regional life of two centuries ago, brought back to life by Maréchal’s pictures.

about this book
Who should read this book
This book is intended for people who already have experience in one or more programming
languages and want to learn the basics of Python 3 as quickly and directly
as possible. Although some basic concepts are covered, there’s no attempt to teach
basic programming skills in this book, and the basic concepts of flow control, OOP,
file access, exception handling, and the like are assumed. This book may also be of
use to users of earlier versions of Python who want a concise reference for Python 3.

How to use this book
Part 1 introduces Python and explains how to download and install it on your system.
It also includes a very general survey of the language, which will be most useful for
experienced programmers looking for a high-level view of Python.
Part 2 is the heart of the book. It covers the ingredients necessary for obtaining a
working knowledge of Python as a general-purpose programming language. The
chapters are designed to allow readers who are beginning to learn Python to work
their way through sequentially, picking up knowledge of the key points of the language.
These chapters also contain some more advanced sections, allowing you to
return to find in one place all the necessary information about a construct or topic.
Part 3 introduces advanced language features of Python, elements of the language
that aren’t essential to its use but that can certainly be a great help to a serious Python programmer.
Part 4 describes more advanced or specialized topics that are beyond the strict syntax
of the language. You may read these chapters or not, depending on your needs.
A suggested plan if you’re new to Python is to start by reading chapter 3 to obtain
an overall perspective and then work through the chapters in part 2 that are applicable.
Enter in the interactive examples as they are introduced. This will immediately
reinforce the concepts. You can also easily go beyond the examples in the text to
answer questions about anything that may be unclear. This has the potential to
amplify the speed of your learning and the level of your comprehension. If you aren’t
familiar with OOP or don’t need it for your application, skip most of chapter 15. If you
aren’t interested in developing a GUI, skip chapter 16.
Those familiar with Python should also start with chapter 3. It will be a good review
and will introduce differences between Python 3 and what may be more familiar. It’s a
reasonable test of whether you’re ready to move on to the advanced chapters in parts
3 and 4 of this book.
It’s possible that some readers, although new to Python, will have enough experience
with other programming languages to be able to pick up the bulk of what they
need to get going from chapter 3 and by browsing the Python standard library modules
listed in chapter 23 and the Python Library Reference in the Python documentation.

Table of Contents
preface xvii
acknowledgments xviii
about this book xx
PART 1 STARTING OUT
1 About Python 3
1.1 Why should I use Python? 3
1.2 What Python does well 4
Python is easy to use 4 ■ Python is expressive 4
Python is readable 5 ■ Python is complete—“batteries
included” 6 ■ Python is cross-platform 6 ■ Python is free 6
1.3 What Python doesn’t do as well 7
Python is not the fastest language 7 ■ Python doesn’t have the
most libraries 8 ■ Python doesn’t check variable types at
compile time 8
1.4 Why learn Python 3? 8
1.5 Summary 9
2 Getting started 10
2.1 Installing Python 10
2.2 IDLE and the basic interactive mode 12
The basic interactive mode 12 ■ The IDLE integrated development
environment 13 ■ Choosing between basic interactive mode and IDLE 14
2.3 Using IDLE’s Python Shell window 14
2.4 Hello, world 15
2.5 Using the interactive prompt to explore Python 15
2.6 Summary 17
3 The Quick Python overview 18
3.1 Python synopsis 19
3.2 Built-in data types 19
Numbers 19 ■ Lists 21 ■ Tuples 22 ■ Strings 23
Dictionaries 24 ■ Sets 24 ■ File objects 25
3.3 Control flow structures 25
Boolean values and expressions 25 ■ The if-elif-else
statement 26 ■ The while loop 26 ■ The for
loop 27 ■ Function definition 27 ■ Exceptions 28
3.4 Module creation 29
3.5 Object-oriented programming 30
3.6 Summary 31
PART 2 THE ESSENTIALS
4 The absolute basics 35
4.1 Indentation and block structuring 35
4.2 Differentiating comments 37
4.3 Variables and assignments 37
4.4 Expressions 38
4.5 Strings 39
4.6 Numbers 40
Built-in numeric functions 41 ■ Advanced numeric
functions 41 ■ Numeric computation 41 ■ Complex
numbers 41 ■ Advanced complex-number functions 42
4.7 The None value 43
4.8 Getting input from the user 43
4.9 Built-in operators 43
4.10 Basic Python style 43
4.11 Summary 44
5 Lists, tuples, and sets 45
5.1 Lists are like arrays 46
5.2 List indices 46
5.3 Modifying lists 48
5.4 Sorting lists 50
Custom sorting 51 ■ The sorted() function 52
5.5 Other common list operations 52
List membership with the in operator 52 ■ List concatenation
with the + operator 53 ■ List initialization with the *
operator 53 ■ List minimum or maximum with min and
max 53 ■ List search with index 53 ■ List matches with
count 54 ■ Summary of list operations 54
5.6 Nested lists and deep copies 55
5.7 Tuples 57
Tuple basics 57 ■ One-element tuples need a
comma 58 ■ Packing and unpacking tuples 58
Converting between lists and tuples 60
5.8 Sets 60
Set operations 60 ■ Frozensets 61
5.9 Summary 62
6 Strings 63
6.1 Strings as sequences of characters 63
6.2 Basic string operations 64
6.3 Special characters and escape sequences 64
Basic escape sequences 65 ■ Numeric (octal and hexadecimal) and
Unicode escape sequences 65 ■ Printing vs. evaluating strings
with special characters 66
6.4 String methods 67
The split and join string methods 67 ■ Converting strings to
numbers 68 ■ Getting rid of extra whitespace 69 ■ String
searching 70 ■ Modifying strings 71 ■ Modifying strings with
list manipulations 73 ■ Useful methods and constants 73
6.5 Converting from objects to strings 74
6.6 Using the format method 76
The format method and positional parameters 76 ■ The format
method and named parameters 76 ■ Format specifiers 77
6.7 Formatting strings with % 77
Using formatting sequences 78 ■ Named parameters and
formatting sequences 78
6.8 Bytes 80
6.9 Summary 80
7 Dictionaries 81
7.1 What is a dictionary? 82
Why dictionaries are called dictionaries 83
7.2 Other dictionary operations 83
7.3 Word counting 86
7.4 What can be used as a key? 86
7.5 Sparse matrices 88
7.6 Dictionaries as caches 88
7.7 Efficiency of dictionaries 89
7.8 Summary 89
8 Control flow 90
8.1 The while loop 90
The break and continue statements 91
8.2 The if-elif-else statement 91
8.3 The for loop 92
The range function 93 ■ Using break and continue in for
loops 94 ■ The for loop and tuple unpacking 94 ■ The
enumerate function 94 ■ The zip function 95
8.4 List and dictionary comprehensions 95
8.5 Statements, blocks, and indentation 96
8.6 Boolean values and expressions 99
Most Python objects can be used as Booleans 99 ■ Comparison and
Boolean operators 100
8.7 Writing a simple program to analyze a text file 101
8.8 Summary 102
9 Functions 103
9.1 Basic function definitions 103
9.2 Function parameter options 105
Positional parameters 105 ■ Passing arguments by parameter
name 106 ■ Variable numbers of arguments 107 ■ Mixing
argument-passing techniques 108
9.3 Mutable objects as arguments 108
9.4 Local, nonlocal, and global variables 109
9.5 Assigning functions to variables 111
9.6 lambda expressions 111
9.7 Generator functions 112
9.8 Decorators 113
9.9 Summary 114
10 Modules and scoping rules 115
10.1 What is a module? 115
10.2 A first module 116
10.3 The import statement 119
10.4 The module search path 119
Where to place your own modules 120
10.5 Private names in modules 121
10.6 Library and third-party modules 122
10.7 Python scoping rules and namespaces 123
10.8 Summary 128
11 Python programs 129
11.1 Creating a very basic program 130
Starting a script from a command line 130 ■ Command-line
arguments 131 ■ Redirecting the input and output of a
script 131 ■ The optparse module 132 ■ Using the fileinput
module 133
11.2 Making a script directly executable on UNIX 135
11.3 Scripts on Mac OS X 135
11.4 Script execution options in Windows 135
Starting a script as a document or shortcut 136 ■ Starting a script
from the Windows Run box 137 ■ Starting a script from a
command window 137 ■ Other Windows options 138
11.5 Scripts on Windows vs. scripts on UNIX 138
11.6 Programs and modules 140
11.7 Distributing Python applications 145
distutils 145 ■ py2exe and py2app 145 ■ Creating executable
programs with freeze 145
11.8 Summary 146
12 Using the filesystem 147
12.1 Paths and pathnames 148
Absolute and relative paths 148 ■ The current working
directory 149 ■ Manipulating pathnames 150 ■ Useful
constants and functions 153
12.2 Getting information about files 154
12.3 More filesystem operations 155
12.4 Processing all files in a directory subtree 156
12.5 Summary 157
13 Reading and writing files 159
13.1 Opening files and file objects 159
13.2 Closing files 160
13.3 Opening files in write or other modes 160
13.4 Functions to read and write text or binary data 161
Using binary mode 163
13.5 Screen input/output and redirection 163
13.6 Reading structured binary data with the struct module 165
13.7 Pickling objects into files 167
13.8 Shelving objects 170
13.9 Summary 171
14 Exceptions 172
14.1 Introduction to exceptions 173
General philosophy of errors and exception handling 173 ■ A more
formal definition of exceptions 175 ■ User-defined exceptions 176
14.2 Exceptions in Python 176
Types of Python exceptions 177 ■ Raising exceptions 178
Catching and handling exceptions 179 ■ Defining new
exceptions 180 ■ Debugging programs with the assert
statement 181 ■ The exception inheritance hierarchy 182
Example: a disk-writing program in Python 182 ■ Example:
exceptions in normal evaluation 183 ■ Where to use
exceptions 184
14.3 Using with 184
14.4 Summary 185
15 Classes and object-oriented programming 186
15.1 Defining classes 187
Using a class instance as a structure or record 187
15.2 Instance variables 188
15.3 Methods 188
15.4 Class variables 190
An oddity with class variables 191
15.5 Static methods and class methods 192
Static methods 192 ■ Class methods 193
15.6 Inheritance 194
15.7 Inheritance with class and instance variables 196
15.8 Private variables and private methods 197
15.9 Using @property for more flexible instance variables 198
15.10 Scoping rules and namespaces for class instances 199
15.11 Destructors and memory management 203
15.12 Multiple inheritance 207
15.13 Summary 208
16 Graphical user interfaces 209
16.1 Installing Tkinter 210
16.2 Starting Tk and using Tkinter 211
16.3 Principles of Tkinter 212
Widgets 212 ■ Named attributes 212 ■ Geometry management
and widget placement 213
16.4 A simple Tkinter application 214
16.5 Creating widgets 215
16.6 Widget placement 216
16.7 Using classes to manage Tkinter applications 218
16.8 What else can Tkinter do? 219
Event handling 220 ■ Canvas and text widgets 221
16.9 Alternatives to Tkinter 221
16.10 Summary 222
PART 3 ADVANCED LANGUAGE FEATURES
17 Regular expressions 225
17.1 What is a regular expression? 225
17.2 Regular expressions with special characters 226
17.3 Regular expressions and raw strings 227
Raw strings to the rescue 228
17.4 Extracting matched text from strings 229
17.5 Substituting text with regular expressions 232
17.6 Summary 233
18 Packages 234
18.1 What is a package? 234
18.2 A first example 235
18.3 A concrete example 236
Basic use of the mathproj package 237 ■ Loading subpackages
and submodules 238 ■ import statements within
packages 239 ■ __init__.py files in packages 239
18.4 The __all__ attribute 240
18.5 Proper use of packages 241
18.6 Summary 241
19 Data types as objects 242
19.1 Types are objects, too 242
19.2 Using types 243
19.3 Types and user-defined classes 243
19.4 Duck typing 245
19.5 Summary 246
20 Advanced object-oriented features 247
20.1 What is a special method attribute? 248
20.2 Making an object behave like a list 249
The __getitem__ special method attribute 249 ■ How it
works 250 ■ Implementing full list functionality 251
20.3 Giving an object full list capability 252
20.4 Subclassing from built-in types 254
Subclassing list 254 ■ Subclassing UserList 255
20.5 When to use special method attributes 256
20.6 Metaclasses 256
20.7 Abstract base classes 258
Using abstract base classes for type checking 259 ■ Creating
abstract base classes 260 ■ Using the @abstractmethod and
@abstractproperty decorators 260
20.8 Summary 262
PART 4 WHERE CAN YOU GO FROM HERE? 
21 Testing your code made easy(-er) 265
21.1 Why you need to have tests 265
21.2 The assert statement 266
Python’s __debug__ variable 266
21.3 Tests in docstrings: doctests 267
Avoiding doctest traps 269 ■ Tweaking doctests with
directives 269 ■ Pros and cons of doctests 270
21.4 Using unit tests to test everything, every time 270
Setting up and running a single test case 270 ■ Running the
test 272 ■ Running multiple tests 272 ■ Unit tests vs.
doctests 273
21.5 Summary 273
22 Moving from Python 2 to Python 3 274
22.1 Porting from 2 to 3 274
Steps in porting from Python 2.x to 3.x 275
22.2 Testing with Python 2.6 and -3 276
22.3 Using 2to3 to convert the code 277
22.4 Testing and common problems 279
22.5 Using the same code for 2 and 3 280
Using Python 2.5 or earlier 280 ■ Writing for Python 3.x and
converting back 281
22.6 Summary 281
23 Using Python libraries 282
23.1 “Batteries included”—the standard library 282
Managing various data types 283 ■ Manipulating files and
storage 284 ■ Accessing operating system services 285 ■ Using
internet protocols and formats 286 ■ Development and debugging
tools and runtime services 286
23.2 Moving beyond the standard library 287
23.3 Adding more Python libraries 287
23.4 Installing Python libraries using setup.py 288
Installing under the home scheme 288 ■ Other installation
options 289
23.5 PyPI, a.k.a. “the Cheese Shop” 289
23.6 Summary 289
24 Network, web, and database programming 290
24.1 Accessing databases in Python 291
Using the sqlite3 database 291
24.2 Network programming in Python 293
Creating an instant HTTP server 293 ■ Writing an HTTP
client 294
24.3 Creating a Python web application 295
Using the web server gateway interface 295 ■ Using the wsgi
library to create a basic web app 295 ■ Using frameworks to create
advanced web apps 296
24.4 Sample project—creating a message wall 297
Creating the database 297 ■ Creating an application
object 298 ■ Adding a form and retrieving its contents
298 ■ Saving the form’s contents 299 ■ Parsing the URL and
retrieving messages 300 ■ Adding an HTML wrapper 303
24.5 Summary 304
appendix 305
index 323

Bookscreen
e-books shop

preface
I’ve been coding in Python for a number of years, longer than any other language I’ve
ever used. I use Python for system administration, for web applications, for database
management, and sometimes just to help myself think clearly.

To be honest, I’m sometimes a little surprised that Python has worn so well. Based
on my earlier experience, I would have expected that by now some other language
would have come along that was faster, cooler, sexier, whatever. Indeed, other languages
have come along, but none that helped me do what I needed to do quite as
effectively as Python. In fact, the more I use Python and the more I understand it, the
more I feel the quality of my programming improve and mature.

This is a second edition, and my mantra in updating has been, “If it ain’t broke,
don’t fix it.” Much of the content has been freshened for Python 3 but is largely as
written in the first edition. Of course, the world of Python has changed since Python
1.5, so in several places I’ve had to make significant changes or add new material. On
those occasions I’ve done my best to make the new material compatible with the clear
and low-key style of the original.

For me, the aim of this book is to share the positive experiences I’ve gotten from
coding in Python by introducing people to Python 3, the latest and, in my opinion,
the best version of Python to date. May your journey be as satisfying as mine has been.

Bruce Payette & Richard Siddaway

Brief Table of Contents

Copyright
Brief Table of Contents
Table of Contents
Praise for the Second Edition
Praise for the First Edition
Preface
Acknowledgments
About this Book
About the Cover Illustration
Chapter 1. Welcome to PowerShell
Chapter 2. Working with types
Chapter 3. Operators and expressions
Chapter 4. Advanced operators and variables
Chapter 5. Flow control in scripts
Chapter 6. PowerShell functions
Chapter 7. Advanced functions and scripts
Chapter 8. Using and authoring modules
Chapter 9. Module manifests and metadata
Chapter 10. Metaprogramming with scriptblocks and dynamic code
Chapter 11. PowerShell remoting
Chapter 12. PowerShell workflows
Chapter 13. PowerShell Jobs
Chapter 14. Errors and exceptions
Chapter 15. Debugging
Chapter 16. Working with providers, files, and CIM
Chapter 17. Working with .NET and events
Chapter 18. Desired State Configuration Chapter
19. Classes in PowerShell
Chapter 20. The PowerShell and runspace APIs
PowerShell 6.0 for Windows, Linux, and macOS
Index
List of Figures
List of Tables
List of Listings

e-books shop
e-books shop
Purchase Now !
Just with Paypal



Book Details
 Price
 4.00
 Pages
 938 p
 File Size 
 11,096 KB
 File Type
 PDF format
 ISBN
 9781633430297
 Copyright©   
 2018 by Manning Publications Co 

About the Author
BRUCE PAYETTE is one of the founding members of the Windows PowerShell team. He is codesigner of the PowerShell language along with Jim Truher and the principal author of the
language implementation. He joined Microsoft in 2001 working on Interix, the POSIX
subsystem for Windows. Shortly after that, he moved to help found the PowerShell project. Prior
to joining Microsoft, he worked at various companies including Softway (the creators of Interix)
and MKS (producers of the MKS Toolkit) building UNIX tools for Windows. He lives in
Bellevue, Washington, with his wife, many computers, and two extremely over-bonded
codependent cats.

RICHARD SIDDAWAY has been using PowerShell since the early beta versions of PowerShell
v1. He has introduced PowerShell to many organizations while producing automation-based
solutions to their problems. He has written, and co-authored, a number of PowerShell books for
Manning including PowerShell in Practice, PowerShell and WMI, and PowerShell in Depth. His
books on Hyper-V and Active Directory contain many practical PowerShell examples. An active
blogger and speaker, Richard has also received Microsoft’s PowerShell MVP award for 10 years.

About the title
By combining introductions, overviews, and how-to examples, the In Action books are designed
to help learning and remembering. According to research in cognitive science, the things people
remember are things they discover during self-motivated exploration.
Although no one at Manning is a cognitive scientist, we are convinced that for learning to
become permanent it must pass through stages of exploration, play, and, interestingly, retelling
of what is being learned. People understand and remember new things, which is to say they
master them, only after actively exploring them. Humans learn in action. An essential part of an
In Action book is that it is example-driven. It encourages the reader to try things out, to play with
new code, and explore new ideas.
There is another, more mundane, reason for the title of this book: Our readers are busy. They use
books to do a job or solve a problem. They need books that allow them to jump in and jump out
easily and learn just what they want just when they want it. They need books that aid them in
action. The books in this series are designed for such readers.

About this Book
Windows PowerShell is the next-generation scripting environment created by Microsoft. It’s
designed to provide a unified solution for Windows scripting and automation, able to access the
wide range of technologies such as .NET, COM, and WMI through a single tool. Since its release
in 2006, PowerShell has become the central component of any Windows management solution.
In addition, due to PowerShell’s comprehensive support for .NET, it has broad application
potential outside of the system administration space. PowerShell can be used for text processing,
general scripting, build management, creating test frameworks, and so on. With PowerShell v6
being available on Linux and macOS as well as Windows, the benefits of PowerShell now
extend cross-platform bringing a unified approach to system management.

The authors have extensive experience with PowerShell. Bruce was one of the principal creators
of PowerShell. Richard has been using PowerShell since it first became available to apply
automation techniques to many organizations. Using many examples, both small and large, this
book illustrates the features of the language and environment and shows how to compose those
features into solutions, quickly and effectively.

Note that, because of the broad scope of the PowerShell product, this book has a commensurately
broad focus. It was not designed as a cookbook of pre-constructed management examples, like
how to deal with Active Directory or how to script Exchange. Instead it provides information
about the core of the PowerShell runtime and how to use it to compose solutions the “PowerShell
Way.” After reading this book, the PowerShell user should be able to take any example written
in other languages like C# or Visual Basic and leverage those examples to build solutions in
PowerShell.

Who should read this book?
This book is designed for anyone who wants to learn PowerShell and use it well. Rather than
simply being a book of recipes to read and apply, this book tries to give the reader a deep
knowledge about how PowerShell works and how to apply it. 
All users of PowerShell should read this book.

So, if you’re a Windows sysadmin, this book is for you. If you’re a developer and you need to
get things done in a hurry, if you’re interested in .NET, or just if you like to experiment with
computers, PowerShell is for you and this book is for you.

Table of Contents
Copyright
Brief Table of Contents
Table of Contents
Praise for the Second Edition
Praise for the First Edition Preface
Acknowledgments
About this Book
About the Cover Illustration
Chapter 1. Welcome to PowerShell
1.1. What is PowerShell?
1.1.1. Shells, command lines, and scripting languages
1.2. PowerShell example code
1.2.1. Navigation and basic operations
1.2.2. Basic expressions and variables
1.2.3. Processing data
1.2.4. Flow-control statements 
1.2.5. Scripts and functions
1.2.6. Remote administration
1.3. Core concepts
1.3.1. Command concepts and terminology
1.3.2. Commands and cmdlets
1.3.3. Command categories
1.3.4. Aliases and elastic syntax
1.4. Parsing the PowerShell language
1.4.1. How PowerShell parses
1.4.2. Quoting
1.4.3. Expression-mode and command-mode parsing
1.4.4. Statement termination
1.4.5. Comment syntax in PowerShell
1.5. How the pipeline works
1.5.1. Pipelines and streaming behavior
1.5.2. Parameters and parameter binding
1.6. Formatting and output
1.6.1. Formatting cmdlets
1.6.2. Outputter cmdlets
1.7. Summary
Chapter 2. Working with types
2.1. Type management in the wild, wild West
2.1.1. Types and classes
2.1.2. PowerShell: A type-promiscuous language
2.1.3. Type system and type adaptation
2.1.4. Finding the available types
2.2. Basic types and literals
2.2.1. String literals
2.2.2. Numbers and numeric literals
2.3. Collections: dictionaries and hashtables
2.3.1. Creating and inspecting hashtables
2.3.2. Ordered hashtables
2.3.3. Modifying and manipulating hashtables
2.3.4. Hashtables as reference types
2.4. Collections: arrays and sequences
2.4.1. Collecting pipeline output as an array
2.4.2. Array indexing
2.4.3. Polymorphism in arrays
2.4.4. Arrays as reference types
2.4.5. Singleton arrays and empty arrays
2.5. Type literals
2.5.1. Type name aliases
2.5.2. Generic type literals
2.5.3. Accessing static members with type literals
2.6. Type conversions
2.6.1. How type conversion works
2.6.2. PowerShell’s type-conversion algorithm
2.6.3. Special type conversions in parameter binding
2.7. Summary
Chapter 3. Operators and expressions
3.1. Arithmetic operators
3.1.1. Addition operator
3.1.2. Multiplication operator
3.1.3. Subtraction, division, and the modulus operators
3.2. Assignment operators
3.2.1. Multiple assignments
3.2.2. Multiple assignments with type qualifiers
3.2.3. Assignment operations as value expressions
3.3. Comparison operators
3.3.1. Scalar comparisons
3.3.2. Comparisons and case sensitivity
3.3.3. Using comparison operators with collections
3.4. Pattern matching and text manipulation
3.4.1. Wildcard patterns and the -like operator
3.4.2. Regular expressions
3.4.3. The -match operator
3.4.4. The -replace operator
3.4.5. The -join operator
3.4.6. The -split operator
3.5. Logical and bitwise operators
3.6. Where() and ForEach() methods
3.6.1. Where() method
3.6.2. ForEach() method
3.7. Summary
Chapter 4. Advanced operators and variables
4.1. Operators for working with types
4.2. Unary operators
4.3. Grouping and subexpressions
4.3.1. Subexpressions $( ... )
4.3.2. Array subexpressions @( ... )
4.4. Array operators
4.4.1. Comma operator
4.4.2. Range operator
4.4.3. Array indexing and slicing
4.4.4. Using the range operator with arrays
4.4.5. Working with multidimensional arrays
4.5. Property and method operators
4.5.1. Dot operator
4.5.2. Static methods and the double-colon operator
4.5.3. Indirect method invocation 
4.6.  Format operator
4.7. Redirection and redirection operators
4.8. Working with variables
4.8.1. Creating variables
4.8.2. Variable name syntax
4.8.3. Working with variable cmdlets
4.8.4. Splatting a variable
4.9. Summary
Chapter 5. Flow control in scripts
5.1. Conditional statement
5.2. Looping statements
5.2.1. while loop
5.2.2. do-while loop
5.2.3. for loop 
5.2.4. foreach loop
5.3. Labels, break, and continue
5.4. switch statement
5.4.1. Basic use of the switch statement
5.4.2. Using wildcard patterns with the switch statement
5.4.3. Using regular expressions with the switch statement 
5.4.4. Processing files with the switch statement
5.4.5. Using the $switch loop enumerator in the switch statement
5.5. Flow control using cmdlets
5.5.1. ForEach-Object cmdlet
5.5.2. Where-Object cmdlet
5.6. Statements as values
5.7. A word about performance
5.8. Summary
Chapter 6. PowerShell functions
6.1. Fundamentals of PowerShell functions
6.1.1. Passing arguments using $args
6.1.2. Example functions: ql and qs
6.2. Declaring formal parameters for a function
6.2.1. Mixing named and positional parameters
6.2.2. Adding type constraints to parameters
6.2.3. Handling variable numbers of arguments
6.2.4. Initializing function parameters with default values
6.2.5. Using switch parameters to define command switches
6.2.6. Switch parameters vs. Boolean parameters
6.3. Returning values from functions
6.3.1. Debugging problems in function output
6.3.2. The return statement
6.4. Using simple functions in a pipeline
6.4.1. Functions with begin, process, and end blocks
6.5. Managing function definitions in a session
6.6. Variable scoping in functions
6.6.1. Declaring variables
6.6.2. Using variable scope modifiers
6.7. Summary
Chapter 7. Advanced functions and scripts
7.1. PowerShell scripts
7.1.1. Script execution policy
7.1.2. Passing arguments to scripts
7.1.3. Exiting scripts and the exit statement
7.1.4. Scopes and scripts
7.1.5. Managing your scripts
7.1.6. Running PowerShell scripts from other applications
7.2. Writing advanced functions and scripts
7.2.1. Specifying script and function attributes
7.2.2. The CmdletBinding attribute
7.2.3. The OutputType attribute
7.2.4. Specifying parameter attributes
7.2.5. Creating parameter aliases with the Alias attribute
7.2.6. Parameter validation attributes
7.3. Dynamic parameters and dynamicParam
7.3.1. Steps for adding a dynamic parameter
7.3.2. When should dynamic parameters be used?
7.4. Cmdlet default parameter values
7.4.1. Creating default values
7.4.2. Modifying default values
7.4.3. Using scriptblocks to determine default value
7.5. Documenting functions and scripts
7.5.1. Automatically generated help fields
7.5.2. Creating manual help content
7.5.3. Comment-based help
7.5.4. Tags used in documentation comments
7.6. Summary
Chapter 8. Using and authoring modules
8.1. The role of a module system
8.1.1. Module roles in PowerShell
8.1.2. Module mashups: composing an application
8.2. Module basics
8.2.1. Module terminology
8.2.2. Modules are single-instance objects
8.3. Working with modules
8.3.1. Finding modules on the system
8.3.2. Loading a module
8.3.3. Removing a loaded module
8.4. Writing script modules
8.4.1. A quick review of scripts
8.4.2. Turning a script into a module
8.4.3. Controlling member visibility with Export-ModuleMember
8.4.4. Installing a module
8.4.5. How scopes work in script modules
8.4.6. Nested modules
8.5. Binary modules
8.5.1. Creating a binary module
8.5.2. Nesting binary modules in script modules
8.6. Summary
Chapter 9. Module manifests and metadata
9.1. Module folder structure 9.2.
Module manifest structure 9.3.
Production manifest elements
9.3.1. Module identity
9.3.2. Runtime dependencies
9.4. Construction manifest elements
9.4.1. The loader manifest elements
9.4.2. Module component load order
9.5. Content manifest elements
9.6. Advanced module operations
9.6.1. The PSModuleInfo object
9.6.2. Using the PSModuleInfo methods
9.6.3. The defining module vs. the calling module
9.6.4. Setting module properties from inside a script module
9.6.5. Controlling when modules can be unloaded
9.6.6. Running an action when a module is removed
9.7. Publishing a module to a PowerShell Gallery
9.7.1. A module to publish
9.7.2. PSData Packaging elements
9.7.3. Publishing a module 
9.7.4. Publishing module updates
9.8. Summary
Chapter 10. Metaprogramming with scriptblocks and dynamic code
10.1. Scriptblock basics
10.1.1. Invoking commands
10.1.2. Getting CommandInfo objects
10.1.3. The scriptblock literal 
10.1.4. Defining functions at runtime
10.2. Building and manipulating objects
10.2.1. Looking at members
10.2.2. Defining synthetic members
10.2.3. Using Add-Member to extend objects
10.2.4. Adding note properties with New-Object
10.3. Using the Select-Object cmdlet
10.4. Dynamic modules
10.4.1. Dynamic script modules
10.4.2. Closures in PowerShell
10.4.3. Creating custom objects from modules
10.5. Steppable pipelines
10.5.1. How steppable pipelines work
10.5.2. Creating a proxy command with steppable pipelines
10.6. A closer look at the type-system plumbing
10.6.1. Adding a property
10.6.2. Shadowing an existing property
10.7. Extending the PowerShell language
10.7.1. Little languages
10.7.2. Type extension
10.8. Building script code at runtime
10.8.1. The Invoke-Expression cmdlet
10.8.2. The ExecutionContext variable
10.8.3. The ExpandString() method
10.8.4. The InvokeScript() method
10.8.5. Mechanisms for creating scriptblocks
10.8.6. Creating functions using the function: drive
10.9. Compiling code with Add-Type
10.9.1. Defining a new .NET class: C#
10.9.2. Defining a new enum at runtime
10.9.3. Dynamic binary modules
10.10. Summary
Chapter 11. PowerShell remoting
11.1. PowerShell remoting overview
11.1.1. Commands with built-in remoting
11.1.2. The PowerShell remoting subsystem
11.1.3. Enabling remoting
11.1.4. Additional setup steps for workgroup environments
11.1.5. Authenticating the connecting user
11.1.6. Enabling remoting in the enterprise
11.2. Applying PowerShell remoting
11.2.1. Basic remoting examples
11.2.2. Adding concurrency to the examples
11.2.3. Solving a real problem: multi-machine monitoring
11.3. PowerShell remoting sessions and persistent connections
11.3.1. Additional session attributes
11.3.2. Using the New-PSSession cmdlet
11.3.3. Interactive sessions
11.3.4. Managing PowerShell sessions
11.3.5. Copying files across a PowerShell remoting session
11.4. Implicit remoting
11.4.1. Using implicit remoting
11.4.2. How implicit remoting works
11.5. Considerations when running commands remotely
11.5.1. Remote session startup directory 
11.5.2. Profiles and remoting
11.5.3. Issues running executables remotely
11.5.4. Using files and scripts
11.5.5. Using local variables in remote sessions
11.5.6. Reading and writing to the console
11.5.7. Remote output vs. local output
11.5.8. Processor architecture issues
11.6. Building custom remoting services
11.6.1. Working with custom configurations
11.6.2. Creating a custom configuration
11.6.3. Access controls and endpoints
11.6.4. Constraining a PowerShell session
11.7. PowerShell Direct
11.8. Summary
Chapter 12. PowerShell workflows
12.1. Workflow overview
12.1.1. Why use workflows
12.1.2. Workflow architecture
12.1.3. Your first workflow
12.1.4. Running a workflow
12.1.5. Cmdlets vs. activities
12.1.6. Workflow restrictions
12.2. Workflow keywords
12.2.1. Parallel 12.2.2.
Sequence 12.2.3.
InlineScript 12.2.4.
Foreach -parallel
12.3. Using workflows effectively
12.3.1. Workflow parameters
12.3.2. Variables in workflows
12.3.3. Nested workflows
12.4. Workflow cmdlets
12.4.1. Workflow execution options
12.4.2. Workflow sessions
12.4.3. Invoking as workflow
12.5. Summary
Chapter 13. PowerShell Jobs
13.1. Background jobs in PowerShell
13.1.1. The job commands
13.1.2. Working with the job cmdlets
13.1.3. Working with multiple jobs
13.1.4. Starting jobs on remote computers
13.1.5. Running jobs in existing sessions
13.1.6. Job types
13.2. Workflows as jobs
13.2.1. Checkpoints
13.2.2. Suspending workflows
13.2.3. Workflows and reboots
13.3. Scheduled jobs
13.3.1. Creating scheduled jobs
13.3.2. Modifying a scheduled job
13.3.3. Managing scheduled jobs
13.4. Summary
Chapter 14. Errors and exceptions
14.1. Error handling
14.1.1. ErrorRecords and the error stream
14.1.2. The $error variable and –ErrorVariable parameter
14.1.3. Determining whether a command had an error
14.1.4. Controlling the actions taken on an error
14.2. Dealing with errors that terminate execution
14.2.1. The try/catch/finally statement
14.2.2. The throw statement 
14.3. PowerShell and the event log
14.3.1. The EventLog cmdlets
14.3.2. Examining the PowerShell event log
14.3.3. Get-WinEvent
14.4. Summary
Chapter 15. Debugging
15.1. Script instrumentation
15.1.1. The Write* cmdlets
15.1.2. Writing events to the event Log
15.1.3. Catching errors with strict mode
15.1.4. Static analysis of scripts
15.2. Capturing session output
15.2.1. Starting the transcript
15.2.2. What gets captured in the transcript
15.3. PowerShell script debugging features
15.3.1. The Set-PSDebug cmdlet
15.3.2. Nested prompts and the Suspend operation
15.4. Command-line debugging
15.4.1. Working with breakpoint objects
15.4.2. Setting breakpoints on commands 15.4.3.
Setting breakpoints on variable assignment 15.4.4.
Debugger limitations and issues
15.5. Beyond scripts
15.5.1. Debugging PowerShell jobs
15.5.2. Debugging remote scripts
15.5.3. Debugging PowerShell runspaces
15.6. Summary
Chapter 16. Working with providers, files, and CIM
16.1. PowerShell providers
16.1.1. PowerShell core cmdlets
16.1.2. Working with PSDrives
16.1.3. Working with paths
16.1.4. The Registry provider
16.2. Files, text, and XML
16.2.1. File processing
16.2.2. Unstructured text
16.2.3. XML structured text processing
16.2.4. Converting text output to objects
16.3. Accessing COM objects
Creating COM objects
Identifying and locating COM classes
Automating Windows with COM Using
Microsoft Word for spell checking Issues
with COM
16.4. Using CIM
16.4.1. The CIM cmdlets
16.4.2. CIM sessions
16.5. Summary
Chapter 17. Working with .NET and events
17.1. .NET and PowerShell
17.1.1. Using .NET from PowerShell
17.1.2. PowerShell and GUIs
17.2. Real-time events
17.2.1. Foundations of event handling
17.2.2. Synchronous events
17.2.3. Asynchronous events
17.2.4. Working with asynchronous .NET events
17.2.5. Asynchronous event handling with scriptblocks
17.2.6. Automatic variables in the event handler 17.2.7.
Dynamic modules and event handler state 17.2.8.
Queued events and the Wait-Event cmdlet 17.2.9.
Working with CIM events
17.2.10. Class-based CIM event registration
17.2.11. Engine events
17.2.12. Generating events in functions and scripts
17.2.13. Remoting and event forwarding
17.2.14. How eventing works
17.3. Summary
Chapter 18. Desired State Configuration
18.1. DSC model and architecture
18.1.1. The need for configuration management
18.1.2. Desired State Configuration model
18.1.3. DSC architecture
18.2. Push mode to a single node
18.2.1. Create configuration
18.2.2. MOF file contents
18.2.3. Applying the configuration
18.2.4. Testing the configuration application
18.2.5. Viewing the current configuration
18.2.6. Removing a configuration
18.3. Pushing to multiple nodes
18.3.1. Parameterizing the computer name
18.3.2. Using configuration data
18.3.3. Configuration data and roles
18.3.4. Issues with push mode
18.4. DSC in pull mode
18.4.1. Pull server architecture
18.4.2. Creating a pull server
18.4.3. Publishing a MOF file
18.5. Configuring the Local Configuration Manager
18.5.1. LCM settings
18.5.2. Configuring LCM to use a pull server
18.6. Partial configurations
18.6.1. Partial configurations: yes or no
18.6.2. Pushing partial configurations
18.6.3. Pulling partial configurations
18.7. Summary
Chapter 19. Classes in PowerShell
19.1. Writing classes in PowerShell
19.1.1. Using properties in a PowerShell class
19.1.2. Class member attributes
19.1.3. PowerShell enumerations
19.2. Methods in PowerShell classes
19.2.1. Method basics
19.2.2. Static methods
19.2.3. Instance methods
19.2.4. Method overloads
19.2.5. Hidden methods
19.2.6. Constructors in PowerShell classes
19.3. Extending existing classes
19.3.1. Creating a derived class
19.3.2. Overriding members on the base class
19.3.3. Extending .NET classes
19.4. Classes, modules, using, and namespaces
The using assembly pattern
The using namespace pattern
The using module pattern
Using modules and namespaces
19.5. Writing class-based DSC resources
19.6. Summary
Chapter 20. The PowerShell and runspace APIs
20.1. PowerShell API basics
20.1.1. Multi-command pipelines
20.1.2. Building pipelines incrementally
20.1.3. Handling execution errors
20.1.4. Adding scripts and statements
20.2. Runspaces and the PowerShell API
20.2.1. Existing runspaces and isolated execution
20.2.2. Creating runspaces
20.2.3. Using runspaces for concurrency
20.3. Runspace pools
20.4. Out-of-process runspaces
20.5. Remote runspaces
20.5.1. Sessions and runspaces
20.5.2. Creating remote runspaces
20.6. Managing runspaces
20.7. Summary
PowerShell 6.0 for Windows, Linux, and macOS
The PowerShell open source project
Terminology
.NET Core Installing
on Windows
PowerShell on Linux and macOS
Known issues
Installation
Using PowerShell v6 on Linux
PowerShell remoting and Linux
DSC and Linux
Installing DSC for Linux
Using DSC for Linux
Summary
Index
List of Figures
List of Tables
List of Listings


Bookscreen
e-books shop


Praise for the Second Edition
First he wrote the language, then he wrote the book.
Jeffrey Snover, Microsoft
Really understanding a scripting language means getting inside the heads of the designers
and developers. Windows PowerShell in Action makes that possible in one really
informative and entertaining book.
Jason Zions, Microsoft
Unleashes the power in PowerShell.
Sam Abraham, SISCO
Who better than the lead language designer to provide the definitive reference on the
PowerShell language!
Keith Hill, Agilent Technologies
If you like to learn by example, there is no better example of examples than Payette’s
incredible book.
Oisin Grehan, .NET Solution Architect & Microsoft PowerShell MVP

Praise for the First Edition
The book on PowerShell. It has all the secrets.
James Truher, PowerShell Program Manager, Microsoft
If all it had going for it was the authoritative pedigree of the writer, it might be worth it, but
it’s also well-written, well-organized, and thorough, which I think makes it invaluable as
both a learning tool and a reference.
Slashdot.org
...an encyclopedic tome of PowerShell scripting bringing the reader through the basics with
simple shell scripts through powerful and flexible scripts any Windows systems
administrator will find immediately useful.
ArsGeek.com
[It gives you] inside information, excellent examples, and a colorful writing style.
Marc van Orsouw (MOW), PowerShell MVP
Loading...
DMCA.com Protection Status