Code Clinic - HL7 Lab - Book 4: Lists, the Data Containers
Split a line and you are holding a list. This book makes that container second nature. You read fields by index, and you meet the error that stops more beginner parsers than any other, the IndexError raised when you ask for a field the message never sent. The fix is not guesswork: check the length first, and you get the pattern for a safe read that returns something sensible instead of crashing when a record arrives with fewer fields than you expected. From there, in for asking whether a value is present anywhere in the list, and then lists start to change. An item can be replaced in place, which is how you clean one field without rebuilding everything around it. Lists grow as you append each parsed segment and shrink as you remove what you do not need. The last chapter collects the helpers worth remembering, the small built-in operations that save you from writing a loop for work Python already does in a single call.
Nineteen A4 pages, in full color. Written in short sentences and plain English, for readers whose first language is not English and clearer for everyone else because of it.
Every code example in this book was run before the page was printed, so the output you read is the output you get. Instant PDF download. By M.R. Sterling.