Libraries
Libraries allow us to apply Python to real tasks. These are a few popular ones, but there are many.
Utilities
-
Specialized containers: counting items, grouping with defaults, named tuples, fast queues.
Counter:+ - & |counts[item]elementsmost_commonsubtracttotalupdatedefaultdict:default_factorygetnamedtuple:_asdict_field_defaults_fields_make_replacedefaults=deque:appendappendleftclearcopycountextendextendleftindexinsertmaxlen=poppopleftremovereverserotateOrderedDict:==move_to_endpopitem -
Calculating and formatting dates and times.
-
Rounding, roots, constants, and logarithms.
-
Random numbers, random picks, shuffled order.
-
Regular expressions: searching, extracting, and replacing text by pattern.
-
Reading the system clock, pausing execution, and measuring elapsed time.
Data analysis
-
Reading and writing spreadsheets.
-
Charts and plots: line, bar, and scatter, built directly from plain Python data.
-
Fast numeric arrays, with math applied to a whole array at once instead of item by item.
-
Tabular data: rows and columns, like a spreadsheet, built on top of NumPy.
APIs
-
Reading and writing JSON data: nested dicts and lists, saved to a file or a string.
-
Fetching data over the internet, like asking a website or API for information.
Web
-
Parsing HTML: finding tags, reading attributes and text, and turning a page into structured data.
Images
-
Opening, editing, and saving images, built around one Image object.
Image:basic operationscropimage modesopening and saving imagesresizerotate and flipImageOps:common ImageOps functionsImageColor:converting color namesImageFilter:applying a filterImageEnhance:enhancing an imageImageChops:comparing and combining imagesconvert:converting between formats
Computer vision
-
Real-time image and video analysis, built directly on NumPy arrays: color spaces, edge detection, face detection.
reading, displaying, saving images:displaying a windowimreadsaving a filebasic operations:croppingresizerotatingdrawing:shapes and linestextthresholding, edge detection:Cannythresholdcontours:finding and drawing contours
Desktop UIs
-
Creating desktop applications: text, buttons, dropdowns, forms, output, etc.
configure:reading and changing optionscommand:binding eventscommand callbacks
Games
-
Build small movement-based games with a pen cursor.
Screen:BackgroundClearCloseColorsSetupturtle cursor:AppearanceCircleColorCustom imagesDotDrawing shapesHideInkMotionPositionsRectangleShapeShowSizeStampingTextTracerInput:Dialog promptsKeyboardMouse
Testing
-
Writing and running tests: assertions, fixtures, and parametrizing.