🧱
🧱 Building with the Larz Stack · STK-101 · Session 7 of 8

Communication & Formats — Talking to the World

Real apps email people, send calendar invites, handle phone numbers, and exchange XML. The stack covers each — correctly, and safely.

⏱ 9 min read📅 Updated 2026-07-26📊 Tables, charts & examples

Beyond money, data and security, applications have to talk to the outside world: send email and calendar invites, handle phone numbers from anywhere, exchange XML with partners, and print codes. Each of these has fiddly, easy-to-get-wrong details — and the Larz Stack has a zero-dependency library that gets them right.

The communication & formats family

Six libraries cover the ways apps reach people and exchange data.

LibraryWhat it does
larzemailBuild, parse and send MIME email (attachments, HTML+text)
larzicaliCalendar (RFC 5545) invites and feeds Google/Apple/Outlook accept
larzphoneParse/validate/format phone numbers to E.164, offline
larzxmlErgonomic XML builder + an XXE-safe parser
larzbarcodeEAN-13 and Code 128 barcodes as SVG
larztuiPretty terminal UI — panels, tables, rules

The theme repeats: each replaces a fiddly task (or an unsafe default) with a small, correct, zero-dependency library.

Correct where it's easy to be wrong

These formats bite you in the details. A calendar invite silently fails if the line folding is wrong; an XML parser is a security hole if it trusts DTDs. The stack handles both.

from larzical import Calendar, Event
from larzemail import Email
from datetime import datetime

cal = Calendar()
cal.add(Event(summary='Kickoff', start=datetime(2026,8,1,15,0)))

# attach the invite to an email, in a few lines:
(Email(subject='Invite', from_addr='me@acme.com', to=['you@x.com'])
    .body(text='See attached.')
    .attach('event.ics', cal.to_ical(), 'text/calendar'))
⚠️
larzxml is safe by construction. Its parser rejects DTDs and entity declarations, so XML external-entity (XXE) and billion-laughs attacks simply can't happen — you don't have to remember to harden anything, unlike most default XML parsers.

Phone numbers and codes

Two more everyday needs: normalising phone numbers and printing scannable codes.

from larzphone import parse
parse('0803 123 4567', region='NG').e164()   # '+2348031234567' — store this

from larzbarcode import ean13
ean13('400638133393').to_svg('product.svg')   # check digit added automatically

🎯 Key takeaways

  • Apps must talk to the world: email, calendars, phone numbers, XML and codes — the stack covers each.
  • larzemail + larzical compose (attach an .ics invite to an email in a few lines).
  • larzxml is XXE-safe by construction; larzphone normalises any number to storable E.164.
  • larzbarcode prints retail/label codes as SVG; larztui makes CLI output readable.

Frequently asked

Why not use Python's built-in email and XML modules?

You can, and the stack builds on them where it makes sense (larzemail wraps the stdlib email package). The value is ergonomics and safety: larzemail turns a multi-step MIME dance into one object, and larzxml's parser is safe against XXE and billion-laughs by default — where the stdlib's is not unless you harden it yourself. Each library removes a common footgun.

Do these have external dependencies?

No — like everything in the Larz Stack, all six are pure Python depending only on the standard library. larzical implements RFC 5545 line-folding itself, larzphone ships its own compact region metadata, larzbarcode carries the standard barcode pattern tables. Nothing is pulled in behind them.

Session 7 of 8 complete

Next up: Testing, Quality & Making It Your Own

Continue to Session 8 →

Related lessons

More in this course

Course home → · Browse all courses →