Knowledgebase

Viewing articles tagged 'python'

Automating File and Folder Tasks Working with the filesystem in volume.WHAT PYTHON DOES WELLRenaming in bulk Sorting files into... Automating Interaction With Web Services Scripted integration.WHAT THIS COVERSFetching data from an API, or sending data to one, on a... Automating Reports and Data Exports Recurring output.WHAT THIS COVERSPulling data, processing it, and producing a file or... Automating Safely Reducing the risk of automation.WHAT AUTOMATION MULTIPLIESBoth correct work and mistakes.WHAT TO... Automation: Everything That Matters, Briefly The summary.BEFORE AUTOMATING ANYTHINGAsk whether the task is necessary at all, and who maintains... Building APIs With Python Programmatic interfaces.WHAT AN API PROVIDESAccess to your application's functionality for other... Building Small Internal Tools Utilities for your own business.WHAT THESE ARESmall programs solving a specific internal... Calling Web Services and APIs Talking to other systems.WHAT AN API CALL INVOLVESSending a request to a URL, and receiving a... Checklist: Before Deploying Python Code Pre-deployment.CODEChanges tested somewhere that is not production No debug mode enabled No... Checklist: Reviewing Python Code What to look for.CORRECTNESSDoes it do what it claims?Are edge cases handled: empty, missing,... Checklist: Starting a New Python Project Setup.STRUCTUREProject folder created Version control initialised Ignore file configured before... Choosing a Python Web Framework The main options.WHAT A FRAMEWORK PROVIDESRouting requests to your code Handling requests and... Choosing an Editor or Development Environment Where you write code.WHAT YOU NEEDSyntax highlighting Indentation that behaves predictably The... Comments and Documentation Explaining code.WHAT COMMENTS SHOULD EXPLAINWhy, not what.WHY NOT WHATThe code already says what... Common Python Mistakes and How to Spot Them Frequent errors.INDENTATION PROBLEMSMixing tabs and spaces.Configure the editor for spaces and... Conditions and Making Decisions Branching.WHAT A CONDITION DOESRuns code only when something is true.THE STRUCTUREIf, optionally... Connecting a Web Application to a Database Persistence.WHAT TO SET UPDatabase credentials in configuration, not code A connection approach... Debugging Effectively Finding the cause.THE METHODEstablish what you expected Establish what happened Find where they... Deciding Whether Python Is the Right Choice Choosing a language.WHEN PYTHON SUITSAutomating something you currently do by hand Processing... Deploying Python Code to Your Hosting Getting code onto the server.THE OPTIONSUploading files directly Pulling from a version control... Dictionaries and Key-Value Data Looking things up.WHAT A DICTIONARY ISA collection of keys, each with an associated value.WHY... Errors and Testing: Everything That Matters, Briefly The summary.READ TRACEBACKS FROM THE BOTTOMThe last line states the error. Then find the last... Fetching Data From Websites Responsibly Retrieval and its limits.WHEN THIS IS APPROPRIATEAn API is offered: use it insteadData is... Functions and Reusing Code Organising logic.WHAT A FUNCTION ISA named block of code you can call, optionally with inputs,... Getting Started: Everything That Matters, Briefly The summary.USE PYTHON 3Python 2 is obsolete. Code written for it does not run without... Handling Command-Line Arguments Making scripts flexible.WHY USE ARGUMENTSSo the same script serves several cases without... Handling Errors Properly Failing well.THE PRINCIPLEAnticipate what can fail, and decide what should happen.WHAT CAN... Handling Forms and User Input Safely Accepting submissions.WHAT TO VALIDATEEvery field Type, length, format and range Whether required... Identifying Tasks Worth Automating Choosing what to script.WHAT SUITS AUTOMATIONRepetitive Rule-based Done frequently Error-prone... Installing and Managing Packages Using other people's code.WHAT A PACKAGE ISReusable code published by someone else.WHY THEY... Installing Dependencies for a Hosted Application Getting libraries in place.WHERE THEY MUST GOInto the virtual environment cPanel created for the... Installing Python on Your Computer Getting set up locally.WHAT TO INSTALLThe current stable version from the official source.WHAT TO... Integrating Python With Existing Systems Connecting things.WHAT THIS USUALLY MEANSMoving data between systems that do not talk to each... Interacting With the Operating System System tasks.WHAT PYTHON CAN DORead environment variables List and manipulate files Run other... Language Fundamentals: Everything That Matters, Briefly The summary.CHOOSE THE RIGHT COLLECTIONA list for a sequence, a dictionary when you look things... Lists and Sequences Ordered collections.WHAT A LIST ISAn ordered collection you can change.WHAT YOU DO WITH THEMAdd... Logging From Hosted Applications Knowing what happened.WHY LOGGING MATTERSYou cannot watch a hosted application run.The log is the... Loops and Repetition Doing something repeatedly.THE TWO KINDSIterating over a collection, and repeating while a... Maintainable Code: Everything That Matters, Briefly The summary.FOLLOW THE COMMUNITY STYLE AND ADOPT A FORMATTERStyle then never gets debated, and... Managing Configuration and Secrets Keeping settings out of code.WHAT COUNTS AS CONFIGURATIONDatabase details API keys File paths... Managing Dependencies Over Time Keeping libraries current.THE TENSIONUpdating breaks things. Not updating accumulates... Managing Environment Variables Configuration for hosted applications.WHAT THEY AREValues available to your application from its... Managing Sessions and Authentication Identifying users.WHAT A SESSION ISA way of remembering a visitor between requests.HOW IT WORKSAn... Modules and Importing Code Using code from elsewhere.WHAT A MODULE ISA Python file whose contents can be used from another... Organising a Python Project Structure.WHAT A SIMPLE PROJECT CONTAINSYour code files A requirements file listing dependencies... Practical Applications: Everything That Matters, Briefly The summary.FOR SENDING MAILSend from your own domain through an authenticated account, never as... Preventing Problems Before They Occur Defensive practice.WHAT PREVENTS MOST BUGSValidating input at the boundary Failing clearly rather... Processing Data in Volume Larger datasets.THE FIRST PROBLEMLoading everything into memory.WHAT TO DO INSTEADProcess in a... Python Applications and Resource Limits Staying within your plan.WHAT LIMITS APPLYMemory Processing Simultaneous processes Entry... Python on Your Hosting: Everything That Matters, Briefly The summary.HOW TO SET IT UPThe Python application feature in cPanel creates the virtual... Python: Everything That Matters, Briefly The whole category in one page.SET UP EVERY PROJECT THE SAME WAYPython 3, a virtual environment,... Reading and Writing Files Working with the filesystem.THE BASIC PATTERNOpen a file, work with it, close it.WHAT TO USEThe... Reading Python Error Messages Understanding tracebacks.WHAT A TRACEBACK ISA record of where the error occurred and how the code... Reference: Python Problems and Where to Look Quick lookup.SCRIPT WILL NOT RUN AT ALLSyntax error, or the wrong interpreter. Read the first... Reference: Python Terms Explained Vocabulary.INTERPRETERThe program that runs Python code.MODULEA Python file whose contents can be... Restarting and Reloading Your Application When changes take effect.WHY A RESTART IS NEEDEDThe application runs as a persistent process... Running Python Applications on Shared Hosting What is possible.WHAT IS AVAILABLEcPanel provides a Python application feature, which sets up and... Running Python Scripts With Cron Scheduled tasks.WHAT CRON ISThe scheduler that runs commands at set times.WHAT TO USE IT... Running Your First Python Script The basic workflow.THE SEQUENCEWrite code in a file with a .py extension Save it Run it from a... Scheduling and Running Automation Reliably Making it happen unattended.WHERE TO SCHEDULECron, on your hosting.WHAT TO SPECIFYFull paths to... Sending Email From Python Programmatic mail.WHEN YOU NEED ITNotifications from scripts Reports delivered automatically... Serving Static Files Images, styles and scripts.WHAT STATIC FILES AREFiles served as they are: images, stylesheets,... Setting Up a Python Application in cPanel The practical steps.WHERE TO STARTThe Python application feature in cPanel.WHAT YOU PROVIDEThe... Structuring Larger Programs Beyond a single file.WHEN TO SPLITWhen a file becomes hard to navigate When parts are reusable... Templates and Producing Pages Generating output.WHAT A TEMPLATE ISA page with placeholders, filled with values when... Testing Without a Formal Framework Pragmatic verification.WHEN THIS APPLIESSmall scripts where formal tests are... Text Processing and Pattern Matching Working with unstructured text.WHAT PYTHON DOES WELLSearching, splitting, replacing and... Troubleshooting Hosted Python Applications When something fails.THE FIRST STEPRead the application log.It usually states the cause... Understanding How Your Application Is Served The request path.WHAT HAPPENSA request arrives at the web server It is passed to your application... Understanding Performance Problems Why code is slow.WHAT TO DO FIRSTMeasure.Never optimise based on where you assume the time... Understanding Python Data Types What values are.NUMBERSWhole numbers and decimals, handled separately.TEXTStrings, written in... Understanding Python Versions Which version to use.WHAT MATTERSPython 3 is current. Python 2 is obsolete and unsupported.WHY... Understanding Request and Response How web applications work.WHAT A REQUEST CONTAINSA method, indicating the intent A path Headers... Understanding Scope Where names are visible.WHAT SCOPE MEANSWhich parts of your code can see a given name.THE BASIC... Understanding Virtual Environments Isolating project dependencies.WHAT THE PROBLEM ISTwo projects needing different versions of the... Using Data Analysis Libraries When to reach for them.WHAT THEY PROVIDETabular data handling, with operations for filtering,... Using Logging Instead of Printing For anything beyond a quick check.WHY LOGGING RATHER THAN PRINTINGLevels, so you can control... Using the Interactive Interpreter Testing ideas quickly.WHAT IT ISA prompt where you type Python and see the result immediately.HOW... Using Version Control Tracking changes.WHY EVEN FOR SMALL PROJECTSYou can return to a working state You can see what... Validating Input and Data Trusting nothing from outside.WHERE UNTRUSTED DATA COMES FROMUsers Files APIs Databases populated... Variables and Assigning Values Storing things.WHAT A VARIABLE ISA name referring to a value.HOW IT WORKSYou assign a value to a... Web Application Security Essentials Protecting what you build.VALIDATE EVERY INPUTAt the server, regardless of browser... Web Development: Everything That Matters, Briefly The summary.CHOOSE AN ESTABLISHED, WELL-DOCUMENTED FRAMEWORKAnswers exist when you are stuck.... What Python Is and What It Is For An introduction.WHAT IT ISA general-purpose programming language, designed to be readable.WHAT IT... Working With Archives and Compressed Files Zip and similar.WHAT PYTHON PROVIDESCreating, reading and extracting common archive formats.WHAT... Working With CSV and Spreadsheet Data Tabular files.WHAT CSV ISPlain text, one record per line, values separated by commas.The most... Working With Data: Everything That Matters, Briefly The summary.ALWAYS SPECIFY THE ENCODING WHEN OPENING FILESDefaults differ between systems,... Working With Databases Persistent structured storage.WHEN TO USE ONEData that outlives the program Data several... Working With Dates and Times Handling time correctly.WHY IT IS DIFFICULTTime zones, formats, and the difference between a date... Working With File Paths Locating files reliably.THE PROBLEMPaths written for one system fail on another.WHAT TO... Working With Images Processing pictures.WHAT PYTHON CAN DOResize Convert formats Crop Compress Read dimensions and... Working With JSON Structured data interchange.WHAT JSON ISA text format for structured data, widely used by web... Working With Numbers Arithmetic and precision.THE TWO MAIN TYPESWhole numbers, and numbers with decimal points.WHAT TO... Working With PDF Files Documents.WHAT PYTHON CAN DOExtract text Merge and split Add pages Produce documents from... Working With Spreadsheet Files Reading and writing workbooks.WHEN TO USE A LIBRARYWhen you must read or produce actual... Working With Text Strings in practice.WHAT A STRING ISA sequence of characters, in quotes.COMMON OPERATIONSJoining... Writing a Reliable Script Beyond working once.WHAT A RELIABLE SCRIPT DOESStates what it is doing Handles failure explicitly... Writing Code Others Can Maintain Beyond yourself.WHAT MAKES CODE MAINTAINABLEClear names Small functions doing one thing Obvious... Writing Readable Python Style that matters.THE PRINCIPLECode is read far more often than written.WHAT THE COMMUNITY... Writing Tests Verifying behaviour automatically.WHAT A TEST ISCode that checks your code does what it...
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot