Knowledgebase

Python: Everything That Matters, Briefly Print

  • python, cron, cpanel, database, security, performance, troubleshooting, guide
  • 0

The whole category in one page.

SET UP EVERY PROJECT THE SAME WAY

Python 3, a virtual environment, pinned dependencies in a requirements file, configuration and secrets outside the code, and version control with the ignore file configured before the first commit.

THE THREE RULES THAT PREVENT MOST SECURITY PROBLEMS

Parameterise every database query, without exception. Escape everything displayed in a page. Validate every input at the server, regardless of browser checks.

And never leave debug mode enabled in production.

NEVER USE ORDINARY DECIMAL NUMBERS FOR MONEY

They cannot represent some values exactly. Use a decimal type designed for exact arithmetic.

ON YOUR HOSTING

cPanel's Python application feature creates the environment and serves the application.

It runs as a persistent process, so restart after any code, dependency or environment change. That is the most common report of all.

For cron, use full paths to both the interpreter and the script — cron inherits nothing.

WHEN SOMETHING FAILS

Read the traceback from the bottom, and the application log first.

Print the value and its type when a result surprises you.

BEFORE OPTIMISING, MEASURE

The assumption about where time goes is usually wrong, and the commonest cause is work repeated inside a loop.

THE TEST FOR ANYTHING YOU BUILD

Could a competent person set this up and change it safely, from the repository alone?


Was this answer helpful?
Back

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


Trustpilot