[{"data":1,"prerenderedAt":3414},["ShallowReactive",2],{"post-cards":3,"categories":733,"post-python-for-php-developers":783},[4,29,44,61,80,102,113,130,147,161,178,192,207,222,235,244,253,267,281,295,305,318,328,338,349,364,376,389,400,411,422,433,444,455,468,481,496,511,525,539,551,562,573,583,593,603,613,623,633,643,653,663,673,683,693,703,713,723],{"path":5,"title":6,"slug":7,"summary":8,"date":9,"readTime":10,"hasImage":11,"category":12,"tags":17,"tagSlugs":28},"\u002Fposts\u002Fbuild-a-qr-code-lambda-and-call-it-from-laravel","Build a QR Code Lambda and Call It From Laravel","build-a-qr-code-lambda-and-call-it-from-laravel","A hands-on, beginner-friendly build: write a tiny Python AWS Lambda that turns text into a QR code, run it locally in Docker with no AWS account, and call it from a Laravel app. Every line of Python is explained for developers coming from PHP.","2026-06-15",10,true,{"id":13,"name":14,"slug":15,"hue":16},7,"AWS","aws",195,[18,19,22,25],{"name":14,"slug":15},{"name":20,"slug":21},"Lambda","lambda",{"name":23,"slug":24},"Docker","docker",{"name":26,"slug":27},"Laravel","laravel",[15,21,24,27],{"path":30,"title":31,"slug":32,"summary":33,"date":9,"readTime":10,"hasImage":11,"category":34,"tags":35,"tagSlugs":43},"\u002Fposts\u002Fdeploy-a-lambda-container-image-with-ecr-and-the-console","Deploy a Lambda Container Image With ECR and the Console","deploy-a-lambda-container-image-with-ecr-and-the-console","You built a QR code Lambda and ran it locally. Now put it on AWS the click-through way: create an Amazon ECR repository, push your image, and create the Lambda from that image in the console. Then test it and optionally expose it with a Function URL your Laravel app can call.",{"id":13,"name":14,"slug":15,"hue":16},[36,37,38,41,42],{"name":14,"slug":15},{"name":20,"slug":21},{"name":39,"slug":40},"ECR","ecr",{"name":23,"slug":24},{"name":26,"slug":27},[15,21,40,24,27],{"path":45,"title":46,"slug":47,"summary":48,"date":9,"readTime":49,"hasImage":11,"category":50,"tags":55,"tagSlugs":60},"\u002Fposts\u002Fpython-for-php-developers","Python for PHP Developers","python-for-php-developers","A friendly tour of Python for developers who already know modern PHP. We map the things you reach for every day, types, arrays, classes, named arguments, match, and enums, onto their Python equivalents so you can read and write Python with confidence.",12,{"id":51,"name":52,"slug":53,"hue":54},8,"Python","python",330,[56,57],{"name":52,"slug":53},{"name":58,"slug":59},"PHP","php",[53,59],{"path":62,"title":63,"slug":64,"summary":65,"date":66,"readTime":67,"hasImage":11,"category":68,"tags":71,"tagSlugs":79},"\u002Fposts\u002Fsolid-principles-modern-php","SOLID Principles in Modern PHP","solid-principles-modern-php","SOLID has not changed in years, but PHP has. Here are the five object-oriented design principles rewritten for PHP 8.5, using typed properties, readonly, enums, constructor promotion, and property hooks to express the same ideas with far less boilerplate.","2026-06-14T12:00:00",9,{"id":69,"name":58,"slug":59,"hue":70},1,264,[72,73,76],{"name":58,"slug":59},{"name":74,"slug":75},"OOP","oop",{"name":77,"slug":78},"Architecture","architecture",[59,75,78],{"path":81,"title":82,"slug":83,"summary":84,"date":85,"readTime":13,"hasImage":86,"category":87,"tags":92,"tagSlugs":101},"\u002Fposts\u002Fgit-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow vs GitHub Flow: Choosing a Branching Strategy for Your Team","git-flow-vs-github-flow-choosing-a-branching-strategy","Git Flow and GitHub Flow take very different approaches to team branching and releases. Let's compare them, see where trunk-based development fits, and sort out how to handle versioned releases, hotfixes, and everything in between.","2026-06-14",false,{"id":88,"name":89,"slug":90,"hue":91},4,"Git","git",158,[93,95,98],{"name":94,"slug":90},"GIT",{"name":96,"slug":97},"Workflow","workflow",{"name":99,"slug":100},"GitHub","github",[90,97,100],{"path":103,"title":104,"slug":105,"summary":106,"date":85,"readTime":13,"hasImage":86,"category":107,"tags":108,"tagSlugs":112},"\u002Fposts\u002Fgithub-flow-keep-your-main-branch-deployable","GitHub Flow: Keep Your Main Branch Deployable","github-flow-keep-your-main-branch-deployable","GitHub Flow is the lightweight branching workflow built on a single rule: anything in main is deployable. Here is the whole loop, branch, pull request, review, merge and deploy, with the git and gh commands and an honest look at where it fits.",{"id":88,"name":89,"slug":90,"hue":91},[109,110,111],{"name":94,"slug":90},{"name":96,"slug":97},{"name":99,"slug":100},[90,97,100],{"path":114,"title":115,"slug":116,"summary":117,"date":118,"readTime":10,"hasImage":11,"category":119,"tags":120,"tagSlugs":129},"\u002Fposts\u002Forchestrating-lambdas-with-step-functions","Orchestrating Lambdas with Step Functions","orchestrating-lambdas-with-step-functions","Step Functions let you wire Lambdas into workflows with retries, branching, and parallelism, but you do not always need them. Here is an honest guide to when a state machine earns its keep, then a real parallel pipeline built with the modern JSONata syntax, deployed with SAM and tested locally.","2026-06-03",{"id":13,"name":14,"slug":15,"hue":16},[121,122,123,126],{"name":14,"slug":15},{"name":20,"slug":21},{"name":124,"slug":125},"Step Functions","step-functions",{"name":127,"slug":128},"Serverless","serverless",[15,21,125,128],{"path":131,"title":132,"slug":133,"summary":134,"date":135,"readTime":136,"hasImage":11,"category":137,"tags":138,"tagSlugs":146},"\u002Fposts\u002Fgive-your-lambda-an-http-front-door","Give Your Lambda an HTTP Front Door","give-your-lambda-an-http-front-door","Your Lambda works, but how should the world call it? This is a practical tour of the options: invoking directly, Lambda function URLs, and Amazon API Gateway, with a clear guide to what each one buys you. Then we build an HTTP API with SAM, test it locally, and call it from a Laravel app.","2026-05-06",11,{"id":13,"name":14,"slug":15,"hue":16},[139,140,141,144,145],{"name":14,"slug":15},{"name":20,"slug":21},{"name":142,"slug":143},"API Gateway","api-gateway",{"name":127,"slug":128},{"name":26,"slug":27},[15,21,143,128,27],{"path":148,"title":149,"slug":150,"summary":151,"date":152,"readTime":10,"hasImage":11,"category":153,"tags":154,"tagSlugs":160},"\u002Fposts\u002Fpackage-a-python-lambda-as-a-docker-image","Package a Python Lambda as a Docker Image","package-a-python-lambda-as-a-docker-image","AWS Lambda is not just zip files. Here is how to package a Python function as a Docker container image, choose between arm64 and x86_64, test it locally with the Runtime Interface Emulator, push it to Amazon ECR, and invoke it directly without any API Gateway in front.","2026-04-08",{"id":13,"name":14,"slug":15,"hue":16},[155,156,157,158,159],{"name":14,"slug":15},{"name":20,"slug":21},{"name":23,"slug":24},{"name":39,"slug":40},{"name":127,"slug":128},[15,21,24,40,128],{"path":162,"title":163,"slug":164,"summary":165,"date":166,"readTime":167,"hasImage":11,"category":168,"tags":169,"tagSlugs":177},"\u002Fposts\u002Fwhats-new-in-php-8-5","What's New in PHP 8.5","whats-new-in-php-8-5","PHP 8.5 leans into composition and ergonomics. Here are its headline features with practical examples: the pipe operator, cloning with property updates, the NoDiscard attribute, array_first and array_last, the new URI extension, and backtraces on fatal errors.","2025-11-22",6,{"id":69,"name":58,"slug":59,"hue":70},[170,171,174],{"name":58,"slug":59},{"name":172,"slug":173},"PHP 8.5","php-8-5",{"name":175,"slug":176},"What's New","whats-new",[59,173,176],{"path":179,"title":180,"slug":181,"summary":182,"date":183,"readTime":167,"hasImage":11,"category":184,"tags":185,"tagSlugs":191},"\u002Fposts\u002Fwhats-new-in-php-8-4","What's New in PHP 8.4","whats-new-in-php-8-4","PHP 8.4 brought one of the biggest syntax additions of the 8.x line. Here are its headline features with practical examples: property hooks, asymmetric visibility, new without parentheses, the array_find family, the Deprecated attribute, and a modern HTML5 DOM parser.","2024-11-23",{"id":69,"name":58,"slug":59,"hue":70},[186,187,190],{"name":58,"slug":59},{"name":188,"slug":189},"PHP 8.4","php-8-4",{"name":175,"slug":176},[59,189,176],{"path":193,"title":194,"slug":195,"summary":196,"date":197,"readTime":198,"hasImage":86,"category":199,"tags":203,"tagSlugs":206},"\u002Fposts\u002Fstarting-with-rust-installation-first-program","Starting with Rust: From Installation to Your First Program","starting-with-rust-installation-first-program","Learn how to install Rust and write your first \"Hello, world!\" program.","2024-03-23",2,{"id":167,"name":200,"slug":201,"hue":202},"Rust","rust-programming",38,[204],{"name":205,"slug":205},"rust",[205],{"path":208,"title":209,"slug":210,"summary":211,"date":212,"readTime":213,"hasImage":11,"category":214,"tags":215,"tagSlugs":221},"\u002Fposts\u002Fwhats-new-in-php-8-3","What's New in PHP 8.3","whats-new-in-php-8-3","PHP 8.3 is a focused release full of quality-of-life wins. Here are its headline features with practical examples: typed class constants, the Override attribute, json_validate, dynamic constant fetch, random string generation, and readonly deep cloning.","2023-11-25",5,{"id":69,"name":58,"slug":59,"hue":70},[216,217,220],{"name":58,"slug":59},{"name":218,"slug":219},"PHP 8.3","php-8-3",{"name":175,"slug":176},[59,219,176],{"path":223,"title":224,"slug":225,"summary":226,"date":227,"readTime":198,"hasImage":86,"category":228,"tags":232,"tagSlugs":234},"\u002Fposts\u002Fflutter-version-management-fvm","Flutter Version Management","flutter-version-management-fvm","Managing multiple Flutter versions does not need not be a headache. Let's jump into FVM and see how it can simplify your Flutter journey.","2023-10-07",{"id":213,"name":229,"slug":230,"hue":231},"Flutter","flutter",230,[233],{"name":230,"slug":230},[230],{"path":236,"title":237,"slug":238,"summary":239,"date":227,"readTime":69,"hasImage":86,"category":240,"tags":241,"tagSlugs":243},"\u002Fposts\u002Fsetting-up-cocoapods-fvm","Setting Up CocoaPods for FVM-managed Flutter Projects","setting-up-cocoapods-fvm","A guide to installing CocoaPods for a Flutter project while using FVM to manage Flutter versions, ensuring a smooth setup for iOS development.",{"id":213,"name":229,"slug":230,"hue":231},[242],{"name":230,"slug":230},[230],{"path":245,"title":246,"slug":247,"summary":248,"date":227,"readTime":69,"hasImage":86,"category":249,"tags":250,"tagSlugs":252},"\u002Fposts\u002Ftroubleshooting-xcode-15-build-issues-flutter","Troubleshooting Xcode 15 Build Issues in Flutter Projects","troubleshooting-xcode-15-build-issues-flutter","Uncovering solutions to common issues faced when updating to Xcode 15 in a Flutter project using an older version of CocoaPods.",{"id":213,"name":229,"slug":230,"hue":231},[251],{"name":230,"slug":230},[230],{"path":254,"title":255,"slug":256,"summary":257,"date":258,"readTime":167,"hasImage":11,"category":259,"tags":260,"tagSlugs":266},"\u002Fposts\u002Fwhats-new-in-php-8-2","What's New in PHP 8.2","whats-new-in-php-8-2","PHP 8.2 polished the type system and the immutability story. Here are its headline features with practical examples: readonly classes, DNF types, standalone null, false and true types, the new Random extension, constants in traits, and sensitive parameter redaction.","2022-12-10",{"id":69,"name":58,"slug":59,"hue":70},[261,262,265],{"name":58,"slug":59},{"name":263,"slug":264},"PHP 8.2","php-8-2",{"name":175,"slug":176},[59,264,176],{"path":268,"title":269,"slug":270,"summary":271,"date":272,"readTime":167,"hasImage":11,"category":273,"tags":274,"tagSlugs":280},"\u002Fposts\u002Fwhats-new-in-php-8-1","What's New in PHP 8.1","whats-new-in-php-8-1","PHP 8.1 is one of the most loved releases of the 8.x line. Here are its headline features with practical examples: enums, readonly properties, first-class callable syntax, fibers, the never return type, and new in initializers.","2021-11-27",{"id":69,"name":58,"slug":59,"hue":70},[275,276,279],{"name":58,"slug":59},{"name":277,"slug":278},"PHP 8.1","php-8-1",{"name":175,"slug":176},[59,278,176],{"path":282,"title":283,"slug":284,"summary":285,"date":286,"readTime":167,"hasImage":11,"category":287,"tags":288,"tagSlugs":294},"\u002Fposts\u002Fwhats-new-in-php-8-0","What's New in PHP 8.0","whats-new-in-php-8-0","PHP 8.0 was a true major version. Here is a tour of its headline features with practical examples: constructor property promotion, named arguments, the match expression, the nullsafe operator, union types, and string helpers that finally read like English.","2020-11-28",{"id":69,"name":58,"slug":59,"hue":70},[289,290,293],{"name":58,"slug":59},{"name":291,"slug":292},"PHP 8.0","php-8-0",{"name":175,"slug":176},[59,292,176],{"path":296,"title":297,"slug":298,"summary":299,"date":300,"readTime":88,"hasImage":86,"category":301,"tags":302,"tagSlugs":304},"\u002Fposts\u002Fgit-tracking-a-remote-branch-upstream-for-changes","Git: Tracking a Remote Branch for Changes","git-tracking-a-remote-branch-upstream-for-changes","When you fork a project, you need a way to pull in changes from the original repository, usually called upstream. Here is how to wire up an upstream remote, actually sync your fork, and set up branch tracking so plain git pull and git push just work.","2018-11-04",{"id":88,"name":89,"slug":90,"hue":91},[303],{"name":94,"slug":90},[90],{"path":306,"title":307,"slug":308,"summary":309,"date":300,"readTime":310,"hasImage":11,"category":311,"tags":315,"tagSlugs":317},"\u002Fposts\u002Fjavascript-array-map-filter-reduce-functions","JavaScript's map, filter, and reduce methods","javascript-array-map-filter-reduce-functions","JavaScript provides some amazing functions that can be called against your arrays to help filter them, manipulate them, or even reduce them down to a single value or grouped values.",3,{"id":198,"name":312,"slug":313,"hue":314},"JavaScript","javascript",92,[316],{"name":312,"slug":313},[313],{"path":319,"title":320,"slug":321,"summary":322,"date":323,"readTime":69,"hasImage":11,"category":324,"tags":325,"tagSlugs":327},"\u002Fposts\u002Fphp-fizzbuzz-example","FizzBuzz in PHP: A Fresh Approach","php-fizzbuzz-example","FizzBuzz is a very popular programming question that tests your logic to see if you can build a simple program.","2018-11-02",{"id":69,"name":58,"slug":59,"hue":70},[326],{"name":58,"slug":59},[59],{"path":329,"title":330,"slug":331,"summary":332,"date":333,"readTime":198,"hasImage":11,"category":334,"tags":335,"tagSlugs":337},"\u002Fposts\u002Fphp-array-reduce","PHP's array_reduce is not only for outputting single values","php-array-reduce","PHP's array_reduce is a simple way to partition a set of data or return a single value. It is super powerful and worth spending time learning.","2018-11-01",{"id":69,"name":58,"slug":59,"hue":70},[336],{"name":58,"slug":59},[59],{"path":339,"title":340,"slug":341,"summary":342,"date":343,"readTime":167,"hasImage":86,"category":344,"tags":345,"tagSlugs":348},"\u002Fposts\u002Fimprove-your-git-workflow-with-git-flow","Improve Your Git Workflow with Git Flow","improve-your-git-workflow-with-git-flow","Git Flow is a structured branching model built around versioned, scheduled releases. Here is how its branches fit together, a hands-on walkthrough of features, releases and hotfixes, and an honest take on when it is still the right call.","2016-12-06",{"id":88,"name":89,"slug":90,"hue":91},[346,347],{"name":94,"slug":90},{"name":96,"slug":97},[90,97],{"path":350,"title":351,"slug":352,"summary":353,"date":354,"readTime":167,"hasImage":86,"category":355,"tags":359,"tagSlugs":363},"\u002Fposts\u002Fusing-css-transitions","Using CSS Transitions","using-css-transitions","CSS transitions are the standard way to apply transitions to your elements, and have been for years, replacing the old approach of using JavaScript. In this article, I'll go through each of the transition properties available, and provide examples of how to use them.","2016-12-05",{"id":310,"name":356,"slug":357,"hue":358},"HTML & CSS","html-css",55,[360],{"name":361,"slug":362},"CSS","css",[362],{"path":365,"title":366,"slug":367,"summary":368,"date":369,"readTime":88,"hasImage":86,"category":370,"tags":371,"tagSlugs":375},"\u002Fposts\u002Fstructuring-your-website-with-html-5-semantics","Structuring Your Website With HTML 5 Semantics","structuring-your-website-with-html-5-semantics","Prior to HTML 5, there was no real markup to help explain the intent behind your HTML code. The goal of HTML 5 was to offer a more readable way of writing your code, so that any author that comes after you can have an easier time going through what you've created.","2016-12-04",{"id":310,"name":356,"slug":357,"hue":358},[372],{"name":373,"slug":374},"HTML","html",[374],{"path":377,"title":378,"slug":379,"summary":380,"date":381,"readTime":198,"hasImage":86,"category":382,"tags":383,"tagSlugs":388},"\u002Fposts\u002Finterpolation-in-stylus-css-pre-processor","Interpolation in Stylus","interpolation-in-stylus-css-pre-processor","You can also use interpolation to improve your functions for reuse, as well as your other code within your stylesheet. The way it works is that you can wrap your expression within {}, which will then be outputted as the identifier.","2016-12-03",{"id":310,"name":356,"slug":357,"hue":358},[384,387],{"name":385,"slug":386},"Stylus","stylus",{"name":361,"slug":362},[386,362],{"path":390,"title":391,"slug":392,"summary":393,"date":394,"readTime":69,"hasImage":86,"category":395,"tags":396,"tagSlugs":399},"\u002Fposts\u002Fcreating-configuration-files-in-stylus-css-pre-processor","Creating Configuration Files In Stylus","creating-configuration-files-in-stylus-css-pre-processor","It's super simple to create a configuration file for instance that would manage your media query break points. You could also use a configuration file for managing colors, font sizes, and other variables such as gutter spacing and more.","2016-12-02",{"id":310,"name":356,"slug":357,"hue":358},[397,398],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":401,"title":402,"slug":403,"summary":404,"date":405,"readTime":88,"hasImage":86,"category":406,"tags":407,"tagSlugs":410},"\u002Fposts\u002Fusing-functions-and-mixins-with-stylus-css-pre-processor","Using Functions and Mixins with Stylus","using-functions-and-mixins-with-stylus-css-pre-processor","Stylus allows you to create functions and mixins of reusable code for your stylesheets. You can also handle mathematical operations, unary operations, and more allowing you complete control over your stylesheets with ease.","2016-12-01",{"id":310,"name":356,"slug":357,"hue":358},[408,409],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":412,"title":413,"slug":414,"summary":415,"date":416,"readTime":198,"hasImage":86,"category":417,"tags":418,"tagSlugs":421},"\u002Fposts\u002Fsetting-variables-in-stylus-css-pre-processor","Setting Variables in Stylus","setting-variables-in-stylus-css-pre-processor","Unlike CSS, in Stylus you can assign expressions to variables that can be reusable throughout your stylesheets.","2016-11-29",{"id":310,"name":356,"slug":357,"hue":358},[419,420],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":423,"title":424,"slug":425,"summary":426,"date":427,"readTime":213,"hasImage":86,"category":428,"tags":429,"tagSlugs":432},"\u002Fposts\u002Fusing-selectors-in-stylus-css-pre-processor","Using Selectors in Stylus","using-selectors-in-stylus-css-pre-processor","Selectors are a way to pick the elements that you want styled. In Stylus, similar to CSS, you can apply a set of styles to any element by separating them by a comma delimited list. Stylus though, also allows you to select multiple elements by separating each on their own line.","2016-11-28",{"id":310,"name":356,"slug":357,"hue":358},[430,431],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":434,"title":435,"slug":436,"summary":437,"date":438,"readTime":69,"hasImage":86,"category":439,"tags":440,"tagSlugs":443},"\u002Fposts\u002Flearning-stylus-a-css-pre-processor","Learning Stylus: A CSS Pre-Processor","learning-stylus-a-css-pre-processor","This mini-series will be a little different to how you may see other articles on my site. Really this article is more geared as notes for me as I go through the documentation for Stylus, and learn the ins and outs of this beautiful language.","2016-11-27",{"id":310,"name":356,"slug":357,"hue":358},[441,442],{"name":361,"slug":362},{"name":385,"slug":386},[362,386],{"path":445,"title":446,"slug":447,"summary":448,"date":449,"readTime":88,"hasImage":86,"category":450,"tags":451,"tagSlugs":454},"\u002Fposts\u002Fbem-methodology-overview-and-naming-conventions","BEM Methodology Overview and Naming Conventions","bem-methodology-overview-and-naming-conventions","BEM or Block Element Modifier is a naming convention used to help organize your code base. In this article, I discuss its uses within your CSS projects.","2016-11-26",{"id":310,"name":356,"slug":357,"hue":358},[452,453],{"name":361,"slug":362},{"name":373,"slug":374},[362,374],{"path":456,"title":457,"slug":458,"summary":459,"date":460,"readTime":69,"hasImage":86,"category":461,"tags":462,"tagSlugs":467},"\u002Fposts\u002Fintroduction-to-ecmascript-6","Introduction to ECMAScript 6","introduction-to-ecmascript-6","The latest in ECMAScript 6 introduces new features to JavaScript which makes it so much more fun to use, while solving problems that have been around for years. The intent of this article is to provide you with resources you can use to start learning ES6 today.","2016-11-25",{"id":198,"name":312,"slug":313,"hue":314},[463,464],{"name":312,"slug":313},{"name":465,"slug":466},"ECMAScript","ecmascript",[313,466],{"path":469,"title":470,"slug":471,"summary":472,"date":473,"readTime":310,"hasImage":86,"category":474,"tags":475,"tagSlugs":480},"\u002Fposts\u002Fbabel-installation-and-configuration","Babel Installation and Configuration","babel-installation-and-configuration","Babel offers a convenient way to transform your ES6 code to JavaScript that all browsers can understand. In this article we'll go over a basic configuration that will enable you to start using it with any project right away.","2016-11-24",{"id":198,"name":312,"slug":313,"hue":314},[476,477],{"name":312,"slug":313},{"name":478,"slug":479},"Babel","babel",[313,479],{"path":482,"title":483,"slug":484,"summary":485,"date":486,"readTime":69,"hasImage":86,"category":487,"tags":488,"tagSlugs":495},"\u002Fposts\u002Fconfiguring-stylus-css-pre-processor-with-gulp-and-sourcemaps","Configuring Stylus CSS Pre-Processor with Gulp and Sourcemaps","configuring-stylus-css-pre-processor-with-gulp-and-sourcemaps","In this article we'll go over how to configure your project to process Stylus files using Gulp. We'll also create source map file which your browser will use to help point you in the right direction of your files when developing","2016-11-23",{"id":198,"name":312,"slug":313,"hue":314},[489,490,491,492],{"name":312,"slug":313},{"name":385,"slug":386},{"name":361,"slug":362},{"name":493,"slug":494},"Gulp","gulp",[313,386,362,494],{"path":497,"title":498,"slug":499,"summary":500,"date":501,"readTime":198,"hasImage":86,"category":502,"tags":503,"tagSlugs":510},"\u002Fposts\u002Fconfiguring-gulp-with-less-css-pre-processor","Configuring Gulp With Less CSS Pre-Processor","configuring-gulp-with-less-css-pre-processor","Less is a CSS pre-processor allowing you to create variables, mixins, and functions in an effort to make your CSS more maintainable.","2016-11-22",{"id":198,"name":312,"slug":313,"hue":314},[504,505,506,509],{"name":493,"slug":494},{"name":312,"slug":313},{"name":507,"slug":508},"Less","less",{"name":361,"slug":362},[494,313,508,362],{"path":512,"title":513,"slug":514,"summary":515,"date":516,"readTime":198,"hasImage":11,"category":517,"tags":518,"tagSlugs":524},"\u002Fposts\u002Fusing-browser-sync-with-gulp-for-live-reloading","Using Browser Sync with Gulp for Live Reloading","using-browser-sync-with-gulp-for-live-reloading","Browser Sync is a nice tool to use while developing. It allows your browser to reload live when changes are made to your files. For instance, assuming we're watching our CSS file for changes we can have the browser auto refresh\u002Fsync when it sees those changes made.","2016-11-21",{"id":198,"name":312,"slug":313,"hue":314},[519,520,523],{"name":312,"slug":313},{"name":521,"slug":522},"Browser Sync","browser-sync",{"name":493,"slug":494},[313,522,494],{"path":526,"title":527,"slug":528,"summary":529,"date":530,"readTime":198,"hasImage":86,"category":531,"tags":532,"tagSlugs":538},"\u002Fposts\u002Fgulp-watch-automate-your-gulp-tasks","Gulp Watch: Automate Your Gulp Tasks","gulp-watch-automate-your-gulp-tasks","Gulp watch is perfect for when you're editing project files since it allows you to not have to run the gulp command manually each time.","2016-11-20",{"id":198,"name":312,"slug":313,"hue":314},[533,534,537],{"name":312,"slug":313},{"name":535,"slug":536},"Yarn","yarn",{"name":493,"slug":494},[313,536,494],{"path":540,"title":541,"slug":542,"summary":543,"date":544,"readTime":167,"hasImage":86,"category":545,"tags":546,"tagSlugs":550},"\u002Fposts\u002Fconfiguring-gulp-on-a-new-project","Configuring Gulp On A New Project","configuring-gulp-on-a-new-project","Gulp may seem like a scary thing to wrap your head around at first, but it's actually quite easy to start using once you understand the basics.","2016-11-19",{"id":198,"name":312,"slug":313,"hue":314},[547,548,549],{"name":312,"slug":313},{"name":493,"slug":494},{"name":535,"slug":536},[313,494,536],{"path":552,"title":553,"slug":554,"summary":555,"date":556,"readTime":310,"hasImage":86,"category":557,"tags":558,"tagSlugs":561},"\u002Fposts\u002Fyarn-publishing-a-package","Yarn: Publishing a Package","yarn-publishing-a-package","Publishing a package to the npm repository has never been simpler. With a few steps, you can create a package that is redistributable to all of your projects.","2016-11-18",{"id":198,"name":312,"slug":313,"hue":314},[559,560],{"name":312,"slug":313},{"name":535,"slug":536},[313,536],{"path":563,"title":564,"slug":565,"summary":566,"date":567,"readTime":310,"hasImage":86,"category":568,"tags":569,"tagSlugs":572},"\u002Fposts\u002Fyarn-fast-and-secure-dependency-management","Yarn: Fast and Secure Dependency Management","yarn-fast-and-secure-dependency-management","Yarn is a super simple dependency management tool which is way faster to use instead of traditional npm. It acts as a drop-in replacement, so you can get started using yarn right away. The best way to install yarn is by using npm.","2016-11-17",{"id":198,"name":312,"slug":313,"hue":314},[570,571],{"name":312,"slug":313},{"name":535,"slug":536},[313,536],{"path":574,"title":575,"slug":576,"summary":577,"date":578,"readTime":69,"hasImage":11,"category":579,"tags":580,"tagSlugs":582},"\u002Fposts\u002Fsupport-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Support for keys in list(), or its new shorthand syntax [] in PHP","support-for-keys-in-list-or-its-new-shorthand-syntax-in-php","Now as of PHP 7.1, you can define the keys of your array that will be parsed when destructuring your arrays. Prior to PHP 7.1, you could only use arrays with numeric indexes. Now with this new addition, our lives just got easier.","2016-11-16",{"id":69,"name":58,"slug":59,"hue":70},[581],{"name":58,"slug":59},[59],{"path":584,"title":585,"slug":586,"summary":587,"date":588,"readTime":69,"hasImage":11,"category":589,"tags":590,"tagSlugs":592},"\u002Fposts\u002Ftype-hinting-with-the-iterable-pseudo-type-in-php","Type Hinting With The Iterable pseudo-type In PHP","type-hinting-with-the-iterable-pseudo-type-in-php","As of PHP 7.1, you can now type hint your method\u002Ffunction arguments with the keyword iterable for handling arrays or even objects that implement the Traversable interface.","2016-11-15",{"id":69,"name":58,"slug":59,"hue":70},[591],{"name":58,"slug":59},[59],{"path":594,"title":595,"slug":596,"summary":597,"date":598,"readTime":69,"hasImage":11,"category":599,"tags":600,"tagSlugs":602},"\u002Fposts\u002Ftype-hinting-callable-functions-in-php","Type Hinting Callable Functions in PHP","type-hinting-callable-functions-in-php","As of PHP 5.4, you can type hint your method arguments with the callable keyword allowing you to enforce the type of data that is passed via your arguments.","2016-11-14",{"id":69,"name":58,"slug":59,"hue":70},[601],{"name":58,"slug":59},[59],{"path":604,"title":605,"slug":606,"summary":607,"date":608,"readTime":69,"hasImage":11,"category":609,"tags":610,"tagSlugs":612},"\u002Fposts\u002Fsetting-visibility-for-your-class-constants-in-php","Setting Visibility for Your Class Constants in PHP","setting-visibility-for-your-class-constants-in-php","Now in PHP 7.1+, you can set different visibility modifiers for each of your class constants. The available visibility modifiers consist of public, protected, and private.","2016-11-13",{"id":69,"name":58,"slug":59,"hue":70},[611],{"name":58,"slug":59},[59],{"path":614,"title":615,"slug":616,"summary":617,"date":618,"readTime":69,"hasImage":11,"category":619,"tags":620,"tagSlugs":622},"\u002Fposts\u002Fanonymous-classes-php","Using Anonymous Classes in PHP","anonymous-classes-php","As of PHP 7, you can now create quick throwaway objects for use within your projects. This can be especially useful for your automated tests, for instance, with allowing you to create quick implementations of your interfaces.","2016-11-12",{"id":69,"name":58,"slug":59,"hue":70},[621],{"name":58,"slug":59},[59],{"path":624,"title":625,"slug":626,"summary":627,"date":628,"readTime":69,"hasImage":11,"category":629,"tags":630,"tagSlugs":632},"\u002Fposts\u002Fsymmetric-array-destructuring-in-php","Symmetric Array Destructuring in PHP","symmetric-array-destructuring-in-php","As of PHP 7.1, you can now use the shorthand array syntax to destructure your arrays for assignment. Previously you would have had to use a function like list, but now you can use the simple new array shorthand syntax.","2016-11-11",{"id":69,"name":58,"slug":59,"hue":70},[631],{"name":58,"slug":59},[59],{"path":634,"title":635,"slug":636,"summary":637,"date":638,"readTime":198,"hasImage":11,"category":639,"tags":640,"tagSlugs":642},"\u002Fposts\u002Fphp-array-map-to-format-your-arrays-without-loops","Using PHP's array_map to format your arrays without loops","php-array-map-to-format-your-arrays-without-loops","So let's face it, loops are a bit boring. So how can we mix it up? Let's assume we have a case where we have a CSV file that we want to quickly parse.","2016-11-10",{"id":69,"name":58,"slug":59,"hue":70},[641],{"name":58,"slug":59},[59],{"path":644,"title":645,"slug":646,"summary":647,"date":648,"readTime":13,"hasImage":11,"category":649,"tags":650,"tagSlugs":652},"\u002Fposts\u002Fsolid-principles-in-php","SOLID Principles in PHP","solid-principles-in-php","The 5 basic principles for Object-Oriented Design, SOLID, were first created in an effort to improve maintainability in our code bases. SOLID is a mnemonic acronym that stands for each of the following principles: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.","2016-11-09",{"id":69,"name":58,"slug":59,"hue":70},[651],{"name":58,"slug":59},[59],{"path":654,"title":655,"slug":656,"summary":657,"date":658,"readTime":69,"hasImage":11,"category":659,"tags":660,"tagSlugs":662},"\u002Fposts\u002Ffiltering-arrays-without-using-loops-in-php","Filtering Arrays Without Using Loops in PHP","filtering-arrays-without-using-loops-in-php","PHP has a built-in function called array_filter that allows you to filter through your arrays without the need for a loop. Personally, this approach feels much cleaner to me and simpler to comprehend.","2016-11-08",{"id":69,"name":58,"slug":59,"hue":70},[661],{"name":58,"slug":59},[59],{"path":664,"title":665,"slug":666,"summary":667,"date":668,"readTime":69,"hasImage":11,"category":669,"tags":670,"tagSlugs":672},"\u002Fposts\u002Fvoid-return-types-in-php","Void Return Types in PHP","void-return-types-in-php","As of PHP 7.1, we can now use void return types within our methods. This is useful for cases where you have methods that are just setting or processing data without the need of returning any values.","2016-11-07",{"id":69,"name":58,"slug":59,"hue":70},[671],{"name":58,"slug":59},[59],{"path":674,"title":675,"slug":676,"summary":677,"date":678,"readTime":69,"hasImage":11,"category":679,"tags":680,"tagSlugs":682},"\u002Fposts\u002Ftype-hinting-with-nullable-types-in-php","Type Hinting with Nullable Types in PHP","type-hinting-with-nullable-types-in-php","As of PHP 7.1, you can now set your type declarations as nullable by simply prefixing them with a question mark ?. In doing so a null value can be passed in as a parameter or returned as a value for your methods.","2016-11-06",{"id":69,"name":58,"slug":59,"hue":70},[681],{"name":58,"slug":59},[59],{"path":684,"title":685,"slug":686,"summary":687,"date":688,"readTime":69,"hasImage":11,"category":689,"tags":690,"tagSlugs":692},"\u002Fposts\u002Fphp-group-multiple-use-declarations","PHP Group Multiple use Declarations","php-group-multiple-use-declarations","As of PHP 7, you can now group your imported classes, functions, and constants from under the same namespace.","2016-11-05",{"id":69,"name":58,"slug":59,"hue":70},[691],{"name":58,"slug":59},[59],{"path":694,"title":695,"slug":696,"summary":697,"date":698,"readTime":69,"hasImage":11,"category":699,"tags":700,"tagSlugs":702},"\u002Fposts\u002Fphp-null-coalescing-operator","PHP Null Coalescing Operator","php-null-coalescing-operator","One of my new favorite additions to PHP 7, is the Null Coalescing Operator. It cleans up your code by removing a tedious step of checking if some value is isset() and not NULL and returning it or if not setting a default.","2016-11-04",{"id":69,"name":58,"slug":59,"hue":70},[701],{"name":58,"slug":59},[59],{"path":704,"title":705,"slug":706,"summary":707,"date":708,"readTime":198,"hasImage":11,"category":709,"tags":710,"tagSlugs":712},"\u002Fposts\u002Fphp-spaceship-operator","PHP Spaceship Operator","php-spaceship-operator","One of the new features to hit PHP 7 is the Spaceship Operator. This new trick helps improve the way you'd compare 2 expressions. In short, the comparison returns 1 of 3 values (-1, 0, or 1) depending on the result of the comparison.","2016-11-03",{"id":69,"name":58,"slug":59,"hue":70},[711],{"name":58,"slug":59},[59],{"path":714,"title":715,"slug":716,"summary":717,"date":718,"readTime":310,"hasImage":11,"category":719,"tags":720,"tagSlugs":722},"\u002Fposts\u002Freturn-type-declarations-in-php","Return Type Declarations in PHP","return-type-declarations-in-php","PHP 7 now makes it possible to declare return types for your methods. This allows you better control over the data that will be returned from each method in your application.","2016-11-02",{"id":69,"name":58,"slug":59,"hue":70},[721],{"name":58,"slug":59},[59],{"path":724,"title":725,"slug":726,"summary":727,"date":728,"readTime":69,"hasImage":11,"category":729,"tags":730,"tagSlugs":732},"\u002Fposts\u002Fscalar-type-hints-php","Scalar Type Hints in PHP","scalar-type-hints-php","Starting with PHP 7.0, it's now possible to declare scalar type hints for your method arguments. Previously, we were able to use array and callable, but now with PHP 7+, we have much more control.","2016-11-01",{"id":69,"name":58,"slug":59,"hue":70},[731],{"name":58,"slug":59},[59],[734,741,747,753,759,765,771,777],{"id":735,"description":736,"extension":737,"hue":70,"meta":738,"name":58,"slug":59,"stem":739,"weight":69,"__hash__":740},"categories\u002Fcategories\u002Fphp.json","PHP articles and tutorials ranging from new language features to using interesting packages.","json",{},"categories\u002Fphp","h_EmN4YMO4b2mBt3MPLs7RvscJx0NBmwDIZPxqPqKLE",{"id":742,"description":743,"extension":737,"hue":314,"meta":744,"name":312,"slug":313,"stem":745,"weight":198,"__hash__":746},"categories\u002Fcategories\u002Fjavascript.json","JavaScript articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fjavascript","7gmVgkw5BRo26i1bFoSv96bwDJ4nTtZcJ9Ud6u5p0yk",{"id":748,"description":749,"extension":737,"hue":358,"meta":750,"name":356,"slug":357,"stem":751,"weight":310,"__hash__":752},"categories\u002Fcategories\u002Fhtml-css.json","HTML & CSS articles and tutorials ranging from new language features to using interesting packages.",{},"categories\u002Fhtml-css","vXvPlRA-iaeCJ64Wi3sLyUR0kqL48zYcZWORRqt8N70",{"id":754,"description":755,"extension":737,"hue":91,"meta":756,"name":89,"slug":90,"stem":757,"weight":88,"__hash__":758},"categories\u002Fcategories\u002Fgit.json","Git articles and tutorials ranging from new language features to different workflows.",{},"categories\u002Fgit","qOqFsFTKI9XB444UodUKW_3AakFadHzW-ss8V-maUmE",{"id":760,"description":761,"extension":737,"hue":231,"meta":762,"name":229,"slug":230,"stem":763,"weight":213,"__hash__":764},"categories\u002Fcategories\u002Fflutter.json","Dive into Flutter, the open-source UI software development toolkit, as we explore its capabilities in creating natively compiled applications for mobile, web, and desktop from a single codebase.",{},"categories\u002Fflutter","aD1moU8CgoYt4FRnSeA4Iy9xxnnopdEKBEYP2arAzdI",{"id":766,"description":767,"extension":737,"hue":202,"meta":768,"name":200,"slug":201,"stem":769,"weight":167,"__hash__":770},"categories\u002Fcategories\u002Frust-programming.json","From setting up your environment to advanced concepts, this is your go-to resource for all things Rust.",{},"categories\u002Frust-programming","LscnqSsk-htWc9yZg9eXaIUJwNfTK5oaZOClYKagNC4",{"id":772,"description":773,"extension":737,"hue":16,"meta":774,"name":14,"slug":15,"stem":775,"weight":13,"__hash__":776},"categories\u002Fcategories\u002Faws.json","Hands-on AWS for builders: Lambda, containers and ECR, API Gateway, Step Functions, and the serverless glue in between.",{},"categories\u002Faws","gU2fpFeHDrBz8RJy54lYK7NJxCnMyma_fblrxDoJByQ",{"id":778,"description":779,"extension":737,"hue":54,"meta":780,"name":52,"slug":53,"stem":781,"weight":51,"__hash__":782},"categories\u002Fcategories\u002Fpython.json","Python for people who already build software: a practical, PHP-developer-friendly path into the language and its ecosystem.",{},"categories\u002Fpython","B6ssFzfg4dLAIzOltx3jcPOk7qghiDxoDD74rhlQ9kU",{"id":784,"title":46,"body":785,"category":3403,"date":9,"description":3404,"extension":3405,"hasImage":11,"meta":3406,"navigation":11,"path":45,"readTime":49,"seo":3407,"slug":47,"stem":3408,"summary":48,"tagSlugs":3409,"tags":3410,"__hash__":3413},"posts\u002Fposts\u002Fpython-for-php-developers.md",{"type":786,"value":787,"toc":3392},"minimark",[788,811,816,835,893,918,929,980,1006,1010,1013,1073,1139,1160,1164,1167,1239,1312,1333,1337,1351,1470,1601,1612,1703,1786,1802,1806,1809,1983,2141,2173,2177,2184,2336,2462,2487,2551,2562,2566,2574,2579,2643,2714,2721,2791,2869,2879,2931,2954,2958,2969,3011,3050,3063,3067,3070,3086,3092,3191,3214,3240,3311,3361,3375,3378,3388],[789,790,791,792,796,797,800,801,804,805,810],"p",{},"If you write modern PHP, you already think in the right shapes: types, classes, enums, ",[793,794,795],"code",{},"match",", named arguments, immutability. Python has all of those too, it just spells them differently, with indentation instead of braces and ",[793,798,799],{},"snake_case"," instead of ",[793,802,803],{},"camelCase",". This guide maps what you know onto Python so you can start reading and writing it quickly, without relearning how to program. If you followed my ",[806,807,809],"a",{"href":808},"\u002Farticles\u002Fpackage-a-python-lambda-as-a-docker-image","AWS Lambda series",", those handlers were Python; this is the language behind them.",[812,813,815],"h2",{"id":814},"running-code-and-managing-packages","Running code and managing packages",[789,817,818,819,822,823,826,827,830,831,834],{},"In PHP you declare dependencies in ",[793,820,821],{},"composer.json",", run ",[793,824,825],{},"composer install",", get a ",[793,828,829],{},"vendor\u002F"," folder and an autoloader, and run a script with ",[793,832,833],{},"php script.php",". Python is the same idea with different nouns.",[836,837,841],"pre",{"className":838,"code":839,"language":59,"meta":840,"style":840},"language-php shiki shiki-themes github-dark github-dark","\u002F\u002F composer.json lists dependencies, then: composer install\nrequire __DIR__ . '\u002Fvendor\u002Fautoload.php';\n\necho \"Hello from PHP\\n\";\n","",[793,842,843,851,872,877],{"__ignoreMap":840},[844,845,847],"span",{"class":846,"line":69},"line",[844,848,850],{"class":849},"sJ8bj","\u002F\u002F composer.json lists dependencies, then: composer install\n",[844,852,853,857,861,864,868],{"class":846,"line":198},[844,854,856],{"class":855},"sOPea","require",[844,858,860],{"class":859},"s8ozJ"," __DIR__",[844,862,863],{"class":855}," .",[844,865,867],{"class":866},"s4wv1"," '\u002Fvendor\u002Fautoload.php'",[844,869,871],{"class":870},"suv1-",";\n",[844,873,874],{"class":846,"line":310},[844,875,876],{"emptyLinePlaceholder":11},"\n",[844,878,879,882,885,888,891],{"class":846,"line":88},[844,880,881],{"class":859},"echo",[844,883,884],{"class":866}," \"Hello from PHP",[844,886,887],{"class":859},"\\n",[844,889,890],{"class":866},"\"",[844,892,871],{"class":870},[836,894,897],{"className":895,"code":896,"language":53,"meta":840,"style":840},"language-python shiki shiki-themes github-dark github-dark","# requirements.txt lists dependencies. Work inside a virtual environment:\nprint(\"Hello from Python\")\n",[793,898,899,904],{"__ignoreMap":840},[844,900,901],{"class":846,"line":69},[844,902,903],{"class":849},"# requirements.txt lists dependencies. Work inside a virtual environment:\n",[844,905,906,909,912,915],{"class":846,"line":198},[844,907,908],{"class":859},"print",[844,910,911],{"class":870},"(",[844,913,914],{"class":866},"\"Hello from Python\"",[844,916,917],{"class":870},")\n",[789,919,920,921,925,926,928],{},"The one new habit is the ",[922,923,924],"strong",{},"virtual environment",". Instead of a per-project ",[793,927,829],{},", you create and \"activate\" an isolated environment so each project has its own packages:",[836,930,934],{"className":931,"code":932,"language":933,"meta":840,"style":840},"language-bash shiki shiki-themes github-dark github-dark","python3 -m venv .venv\nsource .venv\u002Fbin\u002Factivate      # Windows: .venv\\Scripts\\activate\npip install requests\npython hello.py\n","bash",[793,935,936,951,962,973],{"__ignoreMap":840},[844,937,938,942,945,948],{"class":846,"line":69},[844,939,941],{"class":940},"sFR8T","python3",[844,943,944],{"class":859}," -m",[844,946,947],{"class":866}," venv",[844,949,950],{"class":866}," .venv\n",[844,952,953,956,959],{"class":846,"line":198},[844,954,955],{"class":859},"source",[844,957,958],{"class":866}," .venv\u002Fbin\u002Factivate",[844,960,961],{"class":849},"      # Windows: .venv\\Scripts\\activate\n",[844,963,964,967,970],{"class":846,"line":310},[844,965,966],{"class":940},"pip",[844,968,969],{"class":866}," install",[844,971,972],{"class":866}," requests\n",[844,974,975,977],{"class":846,"line":88},[844,976,53],{"class":940},[844,978,979],{"class":866}," hello.py\n",[789,981,982,983,986,987,989,990,992,993,996,997,1000,1001,1005],{},"Think of ",[793,984,985],{},"venv"," as a ",[793,988,829],{}," directory you switch on, ",[793,991,966],{}," as Composer, and ",[793,994,995],{},"requirements.txt"," as the dependency list. The other immediate shift: no ",[793,998,999],{},"$"," on variables, no semicolons, and no curly braces. Indentation ",[1002,1003,1004],"em",{},"is"," the block syntax, so a misaligned line is a real error, not a style nit.",[812,1007,1009],{"id":1008},"syntax-basics","Syntax basics",[789,1011,1012],{},"Less ceremony, same ideas. The thing you will miss most at first is string interpolation, and Python's f-strings fill the gap nicely.",[836,1014,1016],{"className":838,"code":1015,"language":59,"meta":840,"style":840},"$name = \"Ada\";\n$count = 3;\necho \"Hello, {$name}! You have {$count} messages.\\n\";\n\u002F\u002F a comment\n",[793,1017,1018,1031,1043,1068],{"__ignoreMap":840},[844,1019,1020,1023,1026,1029],{"class":846,"line":69},[844,1021,1022],{"class":870},"$name ",[844,1024,1025],{"class":855},"=",[844,1027,1028],{"class":866}," \"Ada\"",[844,1030,871],{"class":870},[844,1032,1033,1036,1038,1041],{"class":846,"line":198},[844,1034,1035],{"class":870},"$count ",[844,1037,1025],{"class":855},[844,1039,1040],{"class":859}," 3",[844,1042,871],{"class":870},[844,1044,1045,1047,1050,1053,1056,1059,1062,1064,1066],{"class":846,"line":310},[844,1046,881],{"class":859},[844,1048,1049],{"class":866}," \"Hello, {",[844,1051,1052],{"class":870},"$name",[844,1054,1055],{"class":866},"}! You have {",[844,1057,1058],{"class":870},"$count",[844,1060,1061],{"class":866},"} messages.",[844,1063,887],{"class":859},[844,1065,890],{"class":866},[844,1067,871],{"class":870},[844,1069,1070],{"class":846,"line":88},[844,1071,1072],{"class":849},"\u002F\u002F a comment\n",[836,1074,1076],{"className":895,"code":1075,"language":53,"meta":840,"style":840},"name = \"Ada\"\ncount = 3\nprint(f\"Hello, {name}! You have {count} messages.\")\n# a comment\n",[793,1077,1078,1088,1098,1134],{"__ignoreMap":840},[844,1079,1080,1083,1085],{"class":846,"line":69},[844,1081,1082],{"class":870},"name ",[844,1084,1025],{"class":855},[844,1086,1087],{"class":866}," \"Ada\"\n",[844,1089,1090,1093,1095],{"class":846,"line":198},[844,1091,1092],{"class":870},"count ",[844,1094,1025],{"class":855},[844,1096,1097],{"class":859}," 3\n",[844,1099,1100,1102,1104,1107,1110,1113,1116,1119,1122,1124,1127,1129,1132],{"class":846,"line":310},[844,1101,908],{"class":859},[844,1103,911],{"class":870},[844,1105,1106],{"class":855},"f",[844,1108,1109],{"class":866},"\"Hello, ",[844,1111,1112],{"class":859},"{",[844,1114,1115],{"class":870},"name",[844,1117,1118],{"class":859},"}",[844,1120,1121],{"class":866},"! You have ",[844,1123,1112],{"class":859},[844,1125,1126],{"class":870},"count",[844,1128,1118],{"class":859},[844,1130,1131],{"class":866}," messages.\"",[844,1133,917],{"class":870},[844,1135,1136],{"class":846,"line":88},[844,1137,1138],{"class":849},"# a comment\n",[789,1140,1141,1142,1144,1145,1148,1149,1152,1153,1156,1157,1159],{},"An f-string is any string prefixed with ",[793,1143,1106],{},", and ",[793,1146,1147],{},"{}"," interpolates an expression, much like ",[793,1150,1151],{},"\"{$var}\""," in PHP. ",[793,1154,1155],{},"print()"," adds a newline for you, so you rarely type ",[793,1158,887],{},".",[812,1161,1163],{"id":1162},"types-and-type-hints","Types and type hints",[789,1165,1166],{},"Everything you learned about types in the PHP 8 era carries over, and the syntax is close enough to read on sight.",[836,1168,1170],{"className":838,"code":1169,"language":59,"meta":840,"style":840},"function greet(string $name, ?int $times = 1): string\n{\n    return str_repeat(\"hi $name \", $times);\n}\n",[793,1171,1172,1208,1213,1234],{"__ignoreMap":840},[844,1173,1174,1177,1180,1182,1185,1188,1191,1194,1196,1199,1202,1205],{"class":846,"line":69},[844,1175,1176],{"class":855},"function",[844,1178,1179],{"class":940}," greet",[844,1181,911],{"class":870},[844,1183,1184],{"class":855},"string",[844,1186,1187],{"class":870}," $name, ",[844,1189,1190],{"class":855},"?int",[844,1192,1193],{"class":870}," $times ",[844,1195,1025],{"class":855},[844,1197,1198],{"class":859}," 1",[844,1200,1201],{"class":870},")",[844,1203,1204],{"class":855},":",[844,1206,1207],{"class":855}," string\n",[844,1209,1210],{"class":846,"line":198},[844,1211,1212],{"class":870},"{\n",[844,1214,1215,1218,1221,1223,1226,1228,1231],{"class":846,"line":310},[844,1216,1217],{"class":855},"    return",[844,1219,1220],{"class":859}," str_repeat",[844,1222,911],{"class":870},[844,1224,1225],{"class":866},"\"hi ",[844,1227,1052],{"class":870},[844,1229,1230],{"class":866}," \"",[844,1232,1233],{"class":870},", $times);\n",[844,1235,1236],{"class":846,"line":88},[844,1237,1238],{"class":870},"}\n",[836,1240,1242],{"className":895,"code":1241,"language":53,"meta":840,"style":840},"def greet(name: str, times: int | None = 1) -> str:\n    return f\"hi {name} \" * (times or 1)\n",[793,1243,1244,1282],{"__ignoreMap":840},[844,1245,1246,1249,1251,1254,1257,1260,1263,1266,1269,1272,1274,1277,1279],{"class":846,"line":69},[844,1247,1248],{"class":855},"def",[844,1250,1179],{"class":940},[844,1252,1253],{"class":870},"(name: ",[844,1255,1256],{"class":859},"str",[844,1258,1259],{"class":870},", times: ",[844,1261,1262],{"class":859},"int",[844,1264,1265],{"class":855}," |",[844,1267,1268],{"class":859}," None",[844,1270,1271],{"class":855}," =",[844,1273,1198],{"class":859},[844,1275,1276],{"class":870},") -> ",[844,1278,1256],{"class":859},[844,1280,1281],{"class":870},":\n",[844,1283,1284,1286,1289,1291,1293,1295,1297,1299,1302,1305,1308,1310],{"class":846,"line":198},[844,1285,1217],{"class":855},[844,1287,1288],{"class":855}," f",[844,1290,1225],{"class":866},[844,1292,1112],{"class":859},[844,1294,1115],{"class":870},[844,1296,1118],{"class":859},[844,1298,1230],{"class":866},[844,1300,1301],{"class":855}," *",[844,1303,1304],{"class":870}," (times ",[844,1306,1307],{"class":855},"or",[844,1309,1198],{"class":859},[844,1311,917],{"class":870},[789,1313,1314,1316,1317,1320,1321,1324,1325,1328,1329,1332],{},[793,1315,1190],{}," becomes ",[793,1318,1319],{},"int | None",", the parameter type goes after a colon, and the return type follows ",[793,1322,1323],{},"->",". The one crucial difference: ",[922,1326,1327],{},"Python does not enforce these hints at runtime."," They document intent and power tools like ",[793,1330,1331],{},"mypy"," and your editor, but Python will happily run with the wrong type. PHP actually checks them. So in Python, hints are a strong convention rather than a guarantee.",[812,1334,1336],{"id":1335},"arrays-become-lists-and-dicts","Arrays become lists and dicts",[789,1338,1339,1340,1343,1344,1347,1348,1159],{},"This is the biggest mental adjustment. PHP's single ",[793,1341,1342],{},"array"," type does two jobs: ordered lists and keyed maps. Python splits them into two types, a ",[793,1345,1346],{},"list"," and a ",[793,1349,1350],{},"dict",[836,1352,1354],{"className":838,"code":1353,"language":59,"meta":840,"style":840},"$nums = [1, 2, 3];\n$user = [\"name\" => \"Ada\", \"role\" => \"admin\"];\n\nforeach ($nums as $n) { echo $n; }\nforeach ($user as $key => $value) { echo \"$key=$value\"; }\n",[793,1355,1356,1383,1412,1416,1435],{"__ignoreMap":840},[844,1357,1358,1361,1363,1366,1369,1372,1375,1377,1380],{"class":846,"line":69},[844,1359,1360],{"class":870},"$nums ",[844,1362,1025],{"class":855},[844,1364,1365],{"class":870}," [",[844,1367,1368],{"class":859},"1",[844,1370,1371],{"class":870},", ",[844,1373,1374],{"class":859},"2",[844,1376,1371],{"class":870},[844,1378,1379],{"class":859},"3",[844,1381,1382],{"class":870},"];\n",[844,1384,1385,1388,1390,1392,1395,1398,1400,1402,1405,1407,1410],{"class":846,"line":198},[844,1386,1387],{"class":870},"$user ",[844,1389,1025],{"class":855},[844,1391,1365],{"class":870},[844,1393,1394],{"class":866},"\"name\"",[844,1396,1397],{"class":855}," =>",[844,1399,1028],{"class":866},[844,1401,1371],{"class":870},[844,1403,1404],{"class":866},"\"role\"",[844,1406,1397],{"class":855},[844,1408,1409],{"class":866}," \"admin\"",[844,1411,1382],{"class":870},[844,1413,1414],{"class":846,"line":310},[844,1415,876],{"emptyLinePlaceholder":11},[844,1417,1418,1421,1424,1427,1430,1432],{"class":846,"line":88},[844,1419,1420],{"class":855},"foreach",[844,1422,1423],{"class":870}," ($nums ",[844,1425,1426],{"class":855},"as",[844,1428,1429],{"class":870}," $n) { ",[844,1431,881],{"class":859},[844,1433,1434],{"class":870}," $n; }\n",[844,1436,1437,1439,1442,1444,1447,1450,1453,1455,1457,1460,1462,1465,1467],{"class":846,"line":213},[844,1438,1420],{"class":855},[844,1440,1441],{"class":870}," ($user ",[844,1443,1426],{"class":855},[844,1445,1446],{"class":870}," $key ",[844,1448,1449],{"class":855},"=>",[844,1451,1452],{"class":870}," $value) { ",[844,1454,881],{"class":859},[844,1456,1230],{"class":866},[844,1458,1459],{"class":870},"$key",[844,1461,1025],{"class":866},[844,1463,1464],{"class":870},"$value",[844,1466,890],{"class":866},[844,1468,1469],{"class":870},"; }\n",[836,1471,1473],{"className":895,"code":1472,"language":53,"meta":840,"style":840},"nums = [1, 2, 3]                          # a list\nuser = {\"name\": \"Ada\", \"role\": \"admin\"}   # a dict\n\nfor n in nums:\n    print(n)\nfor key, value in user.items():\n    print(f\"{key}={value}\")\n",[793,1474,1475,1500,1533,1537,1551,1559,1571],{"__ignoreMap":840},[844,1476,1477,1480,1482,1484,1486,1488,1490,1492,1494,1497],{"class":846,"line":69},[844,1478,1479],{"class":870},"nums ",[844,1481,1025],{"class":855},[844,1483,1365],{"class":870},[844,1485,1368],{"class":859},[844,1487,1371],{"class":870},[844,1489,1374],{"class":859},[844,1491,1371],{"class":870},[844,1493,1379],{"class":859},[844,1495,1496],{"class":870},"]                          ",[844,1498,1499],{"class":849},"# a list\n",[844,1501,1502,1505,1507,1510,1512,1515,1518,1520,1522,1524,1527,1530],{"class":846,"line":198},[844,1503,1504],{"class":870},"user ",[844,1506,1025],{"class":855},[844,1508,1509],{"class":870}," {",[844,1511,1394],{"class":866},[844,1513,1514],{"class":870},": ",[844,1516,1517],{"class":866},"\"Ada\"",[844,1519,1371],{"class":870},[844,1521,1404],{"class":866},[844,1523,1514],{"class":870},[844,1525,1526],{"class":866},"\"admin\"",[844,1528,1529],{"class":870},"}   ",[844,1531,1532],{"class":849},"# a dict\n",[844,1534,1535],{"class":846,"line":310},[844,1536,876],{"emptyLinePlaceholder":11},[844,1538,1539,1542,1545,1548],{"class":846,"line":88},[844,1540,1541],{"class":855},"for",[844,1543,1544],{"class":870}," n ",[844,1546,1547],{"class":855},"in",[844,1549,1550],{"class":870}," nums:\n",[844,1552,1553,1556],{"class":846,"line":213},[844,1554,1555],{"class":859},"    print",[844,1557,1558],{"class":870},"(n)\n",[844,1560,1561,1563,1566,1568],{"class":846,"line":167},[844,1562,1541],{"class":855},[844,1564,1565],{"class":870}," key, value ",[844,1567,1547],{"class":855},[844,1569,1570],{"class":870}," user.items():\n",[844,1572,1573,1575,1577,1579,1581,1583,1586,1588,1590,1592,1595,1597,1599],{"class":846,"line":13},[844,1574,1555],{"class":859},[844,1576,911],{"class":870},[844,1578,1106],{"class":855},[844,1580,890],{"class":866},[844,1582,1112],{"class":859},[844,1584,1585],{"class":870},"key",[844,1587,1118],{"class":859},[844,1589,1025],{"class":866},[844,1591,1112],{"class":859},[844,1593,1594],{"class":870},"value",[844,1596,1118],{"class":859},[844,1598,890],{"class":866},[844,1600,917],{"class":870},[789,1602,1603,1604,1607,1608,1611],{},"You iterate a dict's pairs with ",[793,1605,1606],{},".items()"," rather than ",[793,1609,1610],{},"as $key => $value",". And the array functions you use to avoid loops have direct counterparts, though the idiomatic Python is usually a comprehension:",[836,1613,1615],{"className":838,"code":1614,"language":59,"meta":840,"style":840},"$doubled = array_map(fn ($n) => $n * 2, $nums);\n$evens   = array_filter($nums, fn ($n) => $n % 2 === 0);\n$total   = array_reduce($nums, fn ($carry, $n) => $carry + $n, 0);\n",[793,1616,1617,1644,1675],{"__ignoreMap":840},[844,1618,1619,1622,1624,1627,1629,1632,1635,1638,1641],{"class":846,"line":69},[844,1620,1621],{"class":870},"$doubled ",[844,1623,1025],{"class":855},[844,1625,1626],{"class":859}," array_map",[844,1628,911],{"class":870},[844,1630,1631],{"class":855},"fn",[844,1633,1634],{"class":870}," ($n) => $n ",[844,1636,1637],{"class":855},"*",[844,1639,1640],{"class":859}," 2",[844,1642,1643],{"class":870},", $nums);\n",[844,1645,1646,1649,1651,1654,1657,1659,1661,1664,1666,1669,1672],{"class":846,"line":198},[844,1647,1648],{"class":870},"$evens   ",[844,1650,1025],{"class":855},[844,1652,1653],{"class":859}," array_filter",[844,1655,1656],{"class":870},"($nums, ",[844,1658,1631],{"class":855},[844,1660,1634],{"class":870},[844,1662,1663],{"class":855},"%",[844,1665,1640],{"class":859},[844,1667,1668],{"class":855}," ===",[844,1670,1671],{"class":859}," 0",[844,1673,1674],{"class":870},");\n",[844,1676,1677,1680,1682,1685,1687,1689,1692,1695,1698,1701],{"class":846,"line":310},[844,1678,1679],{"class":870},"$total   ",[844,1681,1025],{"class":855},[844,1683,1684],{"class":859}," array_reduce",[844,1686,1656],{"class":870},[844,1688,1631],{"class":855},[844,1690,1691],{"class":870}," ($carry, $n) => $carry ",[844,1693,1694],{"class":855},"+",[844,1696,1697],{"class":870}," $n, ",[844,1699,1700],{"class":859},"0",[844,1702,1674],{"class":870},[836,1704,1706],{"className":895,"code":1705,"language":53,"meta":840,"style":840},"doubled = [n * 2 for n in nums]            # list comprehension\nevens   = [n for n in nums if n % 2 == 0]\ntotal   = sum(nums)                        # functools.reduce exists for the general case\n",[793,1707,1708,1735,1770],{"__ignoreMap":840},[844,1709,1710,1713,1715,1718,1720,1722,1725,1727,1729,1732],{"class":846,"line":69},[844,1711,1712],{"class":870},"doubled ",[844,1714,1025],{"class":855},[844,1716,1717],{"class":870}," [n ",[844,1719,1637],{"class":855},[844,1721,1640],{"class":859},[844,1723,1724],{"class":855}," for",[844,1726,1544],{"class":870},[844,1728,1547],{"class":855},[844,1730,1731],{"class":870}," nums]            ",[844,1733,1734],{"class":849},"# list comprehension\n",[844,1736,1737,1740,1742,1744,1746,1748,1750,1753,1756,1758,1760,1762,1765,1767],{"class":846,"line":198},[844,1738,1739],{"class":870},"evens   ",[844,1741,1025],{"class":855},[844,1743,1717],{"class":870},[844,1745,1541],{"class":855},[844,1747,1544],{"class":870},[844,1749,1547],{"class":855},[844,1751,1752],{"class":870}," nums ",[844,1754,1755],{"class":855},"if",[844,1757,1544],{"class":870},[844,1759,1663],{"class":855},[844,1761,1640],{"class":859},[844,1763,1764],{"class":855}," ==",[844,1766,1671],{"class":859},[844,1768,1769],{"class":870},"]\n",[844,1771,1772,1775,1777,1780,1783],{"class":846,"line":310},[844,1773,1774],{"class":870},"total   ",[844,1776,1025],{"class":855},[844,1778,1779],{"class":859}," sum",[844,1781,1782],{"class":870},"(nums)                        ",[844,1784,1785],{"class":849},"# functools.reduce exists for the general case\n",[789,1787,1788,1789,1792,1793,1796,1797,1801],{},"A list comprehension reads as \"this expression, for each item, optionally where a condition holds.\" Once it clicks, it replaces most of your ",[793,1790,1791],{},"array_map","\u002F",[793,1794,1795],{},"array_filter"," reflexes. (For more on that PHP style, see ",[806,1798,1800],{"href":1799},"\u002Farticles\u002Fphp-array-map-to-format-your-arrays-without-loops","array_map without loops",".)",[812,1803,1805],{"id":1804},"functions","Functions",[789,1807,1808],{},"Defaults, named arguments, and variadics all have clean equivalents. PHP 8's named arguments in particular map almost one to one.",[836,1810,1812],{"className":838,"code":1811,"language":59,"meta":840,"style":840},"function box(int $w, int $h, string $color = \"black\"): array\n{\n    return compact(\"w\", \"h\", \"color\");\n}\n$b = box(w: 4, h: 3, color: \"red\");        \u002F\u002F named arguments (PHP 8.0)\n\nfunction total(...$nums): int { return array_sum($nums); }\n$add = fn ($a, $b) => $a + $b;             \u002F\u002F arrow function\n",[793,1813,1814,1850,1854,1878,1882,1926,1930,1962],{"__ignoreMap":840},[844,1815,1816,1818,1821,1823,1825,1828,1830,1833,1835,1838,1840,1843,1845,1847],{"class":846,"line":69},[844,1817,1176],{"class":855},[844,1819,1820],{"class":940}," box",[844,1822,911],{"class":870},[844,1824,1262],{"class":855},[844,1826,1827],{"class":870}," $w, ",[844,1829,1262],{"class":855},[844,1831,1832],{"class":870}," $h, ",[844,1834,1184],{"class":855},[844,1836,1837],{"class":870}," $color ",[844,1839,1025],{"class":855},[844,1841,1842],{"class":866}," \"black\"",[844,1844,1201],{"class":870},[844,1846,1204],{"class":855},[844,1848,1849],{"class":855}," array\n",[844,1851,1852],{"class":846,"line":198},[844,1853,1212],{"class":870},[844,1855,1856,1858,1861,1863,1866,1868,1871,1873,1876],{"class":846,"line":310},[844,1857,1217],{"class":855},[844,1859,1860],{"class":859}," compact",[844,1862,911],{"class":870},[844,1864,1865],{"class":866},"\"w\"",[844,1867,1371],{"class":870},[844,1869,1870],{"class":866},"\"h\"",[844,1872,1371],{"class":870},[844,1874,1875],{"class":866},"\"color\"",[844,1877,1674],{"class":870},[844,1879,1880],{"class":846,"line":88},[844,1881,1238],{"class":870},[844,1883,1884,1887,1889,1891,1893,1896,1898,1901,1903,1906,1908,1910,1912,1915,1917,1920,1923],{"class":846,"line":213},[844,1885,1886],{"class":870},"$b ",[844,1888,1025],{"class":855},[844,1890,1820],{"class":940},[844,1892,911],{"class":870},[844,1894,1895],{"class":940},"w",[844,1897,1514],{"class":870},[844,1899,1900],{"class":859},"4",[844,1902,1371],{"class":870},[844,1904,1905],{"class":940},"h",[844,1907,1514],{"class":870},[844,1909,1379],{"class":859},[844,1911,1371],{"class":870},[844,1913,1914],{"class":940},"color",[844,1916,1514],{"class":870},[844,1918,1919],{"class":866},"\"red\"",[844,1921,1922],{"class":870},");        ",[844,1924,1925],{"class":849},"\u002F\u002F named arguments (PHP 8.0)\n",[844,1927,1928],{"class":846,"line":167},[844,1929,876],{"emptyLinePlaceholder":11},[844,1931,1932,1934,1937,1939,1942,1945,1947,1950,1953,1956,1959],{"class":846,"line":13},[844,1933,1176],{"class":855},[844,1935,1936],{"class":940}," total",[844,1938,911],{"class":870},[844,1940,1941],{"class":855},"...",[844,1943,1944],{"class":870},"$nums)",[844,1946,1204],{"class":855},[844,1948,1949],{"class":855}," int",[844,1951,1952],{"class":870}," { ",[844,1954,1955],{"class":855},"return",[844,1957,1958],{"class":859}," array_sum",[844,1960,1961],{"class":870},"($nums); }\n",[844,1963,1964,1967,1969,1972,1975,1977,1980],{"class":846,"line":51},[844,1965,1966],{"class":870},"$add ",[844,1968,1025],{"class":855},[844,1970,1971],{"class":855}," fn",[844,1973,1974],{"class":870}," ($a, $b) => $a ",[844,1976,1694],{"class":855},[844,1978,1979],{"class":870}," $b;             ",[844,1981,1982],{"class":849},"\u002F\u002F arrow function\n",[836,1984,1986],{"className":895,"code":1985,"language":53,"meta":840,"style":840},"def box(w: int, h: int, color: str = \"black\") -> dict:\n    return {\"w\": w, \"h\": h, \"color\": color}\n\nb = box(w=4, h=3, color=\"red\")             # keyword arguments\n\ndef total(*nums):                          # *args collects extra positionals\n    return sum(nums)\n\ndef add(a, b):                             # prefer def; lambda exists for one-liners\n    return a + b\n",[793,1987,1988,2019,2040,2044,2083,2087,2103,2112,2116,2129],{"__ignoreMap":840},[844,1989,1990,1992,1994,1997,1999,2002,2004,2007,2009,2011,2013,2015,2017],{"class":846,"line":69},[844,1991,1248],{"class":855},[844,1993,1820],{"class":940},[844,1995,1996],{"class":870},"(w: ",[844,1998,1262],{"class":859},[844,2000,2001],{"class":870},", h: ",[844,2003,1262],{"class":859},[844,2005,2006],{"class":870},", color: ",[844,2008,1256],{"class":859},[844,2010,1271],{"class":855},[844,2012,1842],{"class":866},[844,2014,1276],{"class":870},[844,2016,1350],{"class":859},[844,2018,1281],{"class":870},[844,2020,2021,2023,2025,2027,2030,2032,2035,2037],{"class":846,"line":198},[844,2022,1217],{"class":855},[844,2024,1509],{"class":870},[844,2026,1865],{"class":866},[844,2028,2029],{"class":870},": w, ",[844,2031,1870],{"class":866},[844,2033,2034],{"class":870},": h, ",[844,2036,1875],{"class":866},[844,2038,2039],{"class":870},": color}\n",[844,2041,2042],{"class":846,"line":310},[844,2043,876],{"emptyLinePlaceholder":11},[844,2045,2046,2049,2051,2054,2057,2059,2061,2063,2065,2067,2069,2071,2073,2075,2077,2080],{"class":846,"line":88},[844,2047,2048],{"class":870},"b ",[844,2050,1025],{"class":855},[844,2052,2053],{"class":870}," box(",[844,2055,1895],{"class":2056},"s-3mD",[844,2058,1025],{"class":855},[844,2060,1900],{"class":859},[844,2062,1371],{"class":870},[844,2064,1905],{"class":2056},[844,2066,1025],{"class":855},[844,2068,1379],{"class":859},[844,2070,1371],{"class":870},[844,2072,1914],{"class":2056},[844,2074,1025],{"class":855},[844,2076,1919],{"class":866},[844,2078,2079],{"class":870},")             ",[844,2081,2082],{"class":849},"# keyword arguments\n",[844,2084,2085],{"class":846,"line":213},[844,2086,876],{"emptyLinePlaceholder":11},[844,2088,2089,2091,2093,2095,2097,2100],{"class":846,"line":167},[844,2090,1248],{"class":855},[844,2092,1936],{"class":940},[844,2094,911],{"class":870},[844,2096,1637],{"class":855},[844,2098,2099],{"class":870},"nums):                          ",[844,2101,2102],{"class":849},"# *args collects extra positionals\n",[844,2104,2105,2107,2109],{"class":846,"line":13},[844,2106,1217],{"class":855},[844,2108,1779],{"class":859},[844,2110,2111],{"class":870},"(nums)\n",[844,2113,2114],{"class":846,"line":51},[844,2115,876],{"emptyLinePlaceholder":11},[844,2117,2118,2120,2123,2126],{"class":846,"line":67},[844,2119,1248],{"class":855},[844,2121,2122],{"class":940}," add",[844,2124,2125],{"class":870},"(a, b):                             ",[844,2127,2128],{"class":849},"# prefer def; lambda exists for one-liners\n",[844,2130,2131,2133,2136,2138],{"class":846,"line":10},[844,2132,1217],{"class":855},[844,2134,2135],{"class":870}," a ",[844,2137,1694],{"class":855},[844,2139,2140],{"class":870}," b\n",[789,2142,2143,2144,2147,2148,2151,2152,1316,2155,2158,2159,2162,2163,2166,2167,2169,2170,2172],{},"PHP's ",[793,2145,2146],{},"name: value"," named arguments become ",[793,2149,2150],{},"name=value"," keyword arguments. Variadic ",[793,2153,2154],{},"...$nums",[793,2156,2157],{},"*nums",", and Python adds ",[793,2160,2161],{},"**kwargs"," for collecting keyword arguments into a dict. Arrow functions (",[793,2164,2165],{},"fn () =>",") have a ",[793,2168,21],{}," equivalent, but a named ",[793,2171,1248],{}," is usually clearer and is what you will see most.",[812,2174,2176],{"id":2175},"classes-and-objects","Classes and objects",[789,2178,2179,2180,2183],{},"Python is object-oriented to its core, so this will feel familiar, with two differences worth internalizing: ",[793,2181,2182],{},"self"," is explicit, and \"private\" is a convention rather than a rule.",[836,2185,2187],{"className":838,"code":2186,"language":59,"meta":840,"style":840},"final class Money\n{\n    public function __construct(\n        public readonly int $amount,\n        private string $currency = \"USD\",\n    ) {}\n\n    public function formatted(): string\n    {\n        return number_format($this->amount \u002F 100, 2) . \" {$this->currency}\";\n    }\n}\n",[793,2188,2189,2200,2204,2218,2231,2250,2255,2259,2275,2280,2327,2332],{"__ignoreMap":840},[844,2190,2191,2194,2197],{"class":846,"line":69},[844,2192,2193],{"class":855},"final",[844,2195,2196],{"class":855}," class",[844,2198,2199],{"class":940}," Money\n",[844,2201,2202],{"class":846,"line":198},[844,2203,1212],{"class":870},[844,2205,2206,2209,2212,2215],{"class":846,"line":310},[844,2207,2208],{"class":855},"    public",[844,2210,2211],{"class":855}," function",[844,2213,2214],{"class":859}," __construct",[844,2216,2217],{"class":870},"(\n",[844,2219,2220,2223,2226,2228],{"class":846,"line":88},[844,2221,2222],{"class":855},"        public",[844,2224,2225],{"class":855}," readonly",[844,2227,1949],{"class":855},[844,2229,2230],{"class":870}," $amount,\n",[844,2232,2233,2236,2239,2242,2244,2247],{"class":846,"line":213},[844,2234,2235],{"class":855},"        private",[844,2237,2238],{"class":855}," string",[844,2240,2241],{"class":870}," $currency ",[844,2243,1025],{"class":855},[844,2245,2246],{"class":866}," \"USD\"",[844,2248,2249],{"class":870},",\n",[844,2251,2252],{"class":846,"line":167},[844,2253,2254],{"class":870},"    ) {}\n",[844,2256,2257],{"class":846,"line":13},[844,2258,876],{"emptyLinePlaceholder":11},[844,2260,2261,2263,2265,2268,2271,2273],{"class":846,"line":51},[844,2262,2208],{"class":855},[844,2264,2211],{"class":855},[844,2266,2267],{"class":940}," formatted",[844,2269,2270],{"class":870},"()",[844,2272,1204],{"class":855},[844,2274,1207],{"class":855},[844,2276,2277],{"class":846,"line":67},[844,2278,2279],{"class":870},"    {\n",[844,2281,2282,2285,2288,2290,2293,2295,2298,2300,2303,2305,2307,2310,2312,2315,2317,2319,2322,2325],{"class":846,"line":10},[844,2283,2284],{"class":855},"        return",[844,2286,2287],{"class":859}," number_format",[844,2289,911],{"class":870},[844,2291,2292],{"class":859},"$this",[844,2294,1323],{"class":855},[844,2296,2297],{"class":870},"amount ",[844,2299,1792],{"class":855},[844,2301,2302],{"class":859}," 100",[844,2304,1371],{"class":870},[844,2306,1374],{"class":859},[844,2308,2309],{"class":870},") ",[844,2311,1159],{"class":855},[844,2313,2314],{"class":866}," \" {",[844,2316,2292],{"class":859},[844,2318,1323],{"class":855},[844,2320,2321],{"class":870},"currency",[844,2323,2324],{"class":866},"}\"",[844,2326,871],{"class":870},[844,2328,2329],{"class":846,"line":136},[844,2330,2331],{"class":870},"    }\n",[844,2333,2334],{"class":846,"line":49},[844,2335,1238],{"class":870},[836,2337,2339],{"className":895,"code":2338,"language":53,"meta":840,"style":840},"from dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass Money:\n    amount: int\n    currency: str = \"USD\"\n\n    def formatted(self) -> str:\n        return f\"{self.amount \u002F 100:.2f} {self.currency}\"\n",[793,2340,2341,2355,2359,2363,2380,2390,2398,2410,2414,2428],{"__ignoreMap":840},[844,2342,2343,2346,2349,2352],{"class":846,"line":69},[844,2344,2345],{"class":855},"from",[844,2347,2348],{"class":870}," dataclasses ",[844,2350,2351],{"class":855},"import",[844,2353,2354],{"class":870}," dataclass\n",[844,2356,2357],{"class":846,"line":198},[844,2358,876],{"emptyLinePlaceholder":11},[844,2360,2361],{"class":846,"line":310},[844,2362,876],{"emptyLinePlaceholder":11},[844,2364,2365,2368,2370,2373,2375,2378],{"class":846,"line":88},[844,2366,2367],{"class":940},"@dataclass",[844,2369,911],{"class":870},[844,2371,2372],{"class":2056},"frozen",[844,2374,1025],{"class":855},[844,2376,2377],{"class":859},"True",[844,2379,917],{"class":870},[844,2381,2382,2385,2388],{"class":846,"line":213},[844,2383,2384],{"class":855},"class",[844,2386,2387],{"class":940}," Money",[844,2389,1281],{"class":870},[844,2391,2392,2395],{"class":846,"line":167},[844,2393,2394],{"class":870},"    amount: ",[844,2396,2397],{"class":859},"int\n",[844,2399,2400,2403,2405,2407],{"class":846,"line":13},[844,2401,2402],{"class":870},"    currency: ",[844,2404,1256],{"class":859},[844,2406,1271],{"class":855},[844,2408,2409],{"class":866}," \"USD\"\n",[844,2411,2412],{"class":846,"line":51},[844,2413,876],{"emptyLinePlaceholder":11},[844,2415,2416,2419,2421,2424,2426],{"class":846,"line":67},[844,2417,2418],{"class":855},"    def",[844,2420,2267],{"class":940},[844,2422,2423],{"class":870},"(self) -> ",[844,2425,1256],{"class":859},[844,2427,1281],{"class":870},[844,2429,2430,2432,2434,2436,2439,2442,2444,2446,2449,2451,2454,2457,2459],{"class":846,"line":10},[844,2431,2284],{"class":855},[844,2433,1288],{"class":855},[844,2435,890],{"class":866},[844,2437,2438],{"class":859},"{self",[844,2440,2441],{"class":870},".amount ",[844,2443,1792],{"class":855},[844,2445,2302],{"class":859},[844,2447,2448],{"class":855},":.2f",[844,2450,1118],{"class":859},[844,2452,2453],{"class":859}," {self",[844,2455,2456],{"class":870},".currency",[844,2458,1118],{"class":859},[844,2460,2461],{"class":866},"\"\n",[789,2463,2464,2465,2467,2468,2472,2473,2476,2477,2480,2481,2483,2484,2486],{},"A ",[793,2466,2367],{}," is Python's answer to ",[806,2469,2471],{"href":2470},"\u002Farticles\u002Fwhats-new-in-php-8-0","constructor property promotion",": it generates the initializer from the typed fields. ",[793,2474,2475],{},"frozen=True"," makes it ",[793,2478,2479],{},"readonly",". Notice every method takes ",[793,2482,2182],{}," as its first parameter, where PHP gives you ",[793,2485,2292],{}," implicitly. If you prefer the long form, it looks like this:",[836,2488,2490],{"className":895,"code":2489,"language":53,"meta":840,"style":840},"class Money:\n    def __init__(self, amount: int, currency: str = \"USD\"):\n        self.amount = amount\n        self._currency = currency   # a leading _ means \"internal, please do not touch\"\n",[793,2491,2492,2500,2524,2536],{"__ignoreMap":840},[844,2493,2494,2496,2498],{"class":846,"line":69},[844,2495,2384],{"class":855},[844,2497,2387],{"class":940},[844,2499,1281],{"class":870},[844,2501,2502,2504,2507,2510,2512,2515,2517,2519,2521],{"class":846,"line":198},[844,2503,2418],{"class":855},[844,2505,2506],{"class":859}," __init__",[844,2508,2509],{"class":870},"(self, amount: ",[844,2511,1262],{"class":859},[844,2513,2514],{"class":870},", currency: ",[844,2516,1256],{"class":859},[844,2518,1271],{"class":855},[844,2520,2246],{"class":866},[844,2522,2523],{"class":870},"):\n",[844,2525,2526,2529,2531,2533],{"class":846,"line":310},[844,2527,2528],{"class":859},"        self",[844,2530,2441],{"class":870},[844,2532,1025],{"class":855},[844,2534,2535],{"class":870}," amount\n",[844,2537,2538,2540,2543,2545,2548],{"class":846,"line":88},[844,2539,2528],{"class":859},[844,2541,2542],{"class":870},"._currency ",[844,2544,1025],{"class":855},[844,2546,2547],{"class":870}," currency   ",[844,2549,2550],{"class":849},"# a leading _ means \"internal, please do not touch\"\n",[789,2552,2553,2554,2557,2558,2561],{},"There is no real ",[793,2555,2556],{},"private"," or ",[793,2559,2560],{},"protected",". A single leading underscore signals \"internal,\" and a double underscore name-mangles to discourage access, but nothing stops a determined caller. Python's culture leans on convention where PHP leans on the compiler.",[812,2563,2565],{"id":2564},"modern-features-you-already-use","Modern features you already use",[789,2567,2568,2569,2573],{},"The recent additions to PHP that you reached for in the ",[806,2570,2572],{"href":2571},"\u002Farticles\u002Fsolid-principles-modern-php","modern SOLID"," era have direct Python analogues.",[789,2575,2576,2578],{},[793,2577,795],{}," exists in both, and Python's version does even more (it can destructure):",[836,2580,2582],{"className":838,"code":2581,"language":59,"meta":840,"style":840},"$label = match ($status) {\n    200, 201 => \"ok\",\n    404 => \"not found\",\n    default => \"unknown\",\n};\n",[793,2583,2584,2597,2614,2626,2638],{"__ignoreMap":840},[844,2585,2586,2589,2591,2594],{"class":846,"line":69},[844,2587,2588],{"class":870},"$label ",[844,2590,1025],{"class":855},[844,2592,2593],{"class":855}," match",[844,2595,2596],{"class":870}," ($status) {\n",[844,2598,2599,2602,2604,2607,2609,2612],{"class":846,"line":198},[844,2600,2601],{"class":859},"    200",[844,2603,1371],{"class":870},[844,2605,2606],{"class":859},"201",[844,2608,1397],{"class":855},[844,2610,2611],{"class":866}," \"ok\"",[844,2613,2249],{"class":870},[844,2615,2616,2619,2621,2624],{"class":846,"line":310},[844,2617,2618],{"class":859},"    404",[844,2620,1397],{"class":855},[844,2622,2623],{"class":866}," \"not found\"",[844,2625,2249],{"class":870},[844,2627,2628,2631,2633,2636],{"class":846,"line":88},[844,2629,2630],{"class":855},"    default",[844,2632,1397],{"class":855},[844,2634,2635],{"class":866}," \"unknown\"",[844,2637,2249],{"class":870},[844,2639,2640],{"class":846,"line":213},[844,2641,2642],{"class":870},"};\n",[836,2644,2646],{"className":895,"code":2645,"language":53,"meta":840,"style":840},"match status:\n    case 200 | 201:\n        label = \"ok\"\n    case 404:\n        label = \"not found\"\n    case _:\n        label = \"unknown\"\n",[793,2647,2648,2655,2670,2680,2689,2698,2705],{"__ignoreMap":840},[844,2649,2650,2652],{"class":846,"line":69},[844,2651,795],{"class":855},[844,2653,2654],{"class":870}," status:\n",[844,2656,2657,2660,2663,2665,2668],{"class":846,"line":198},[844,2658,2659],{"class":855},"    case",[844,2661,2662],{"class":859}," 200",[844,2664,1265],{"class":855},[844,2666,2667],{"class":859}," 201",[844,2669,1281],{"class":870},[844,2671,2672,2675,2677],{"class":846,"line":310},[844,2673,2674],{"class":870},"        label ",[844,2676,1025],{"class":855},[844,2678,2679],{"class":866}," \"ok\"\n",[844,2681,2682,2684,2687],{"class":846,"line":88},[844,2683,2659],{"class":855},[844,2685,2686],{"class":859}," 404",[844,2688,1281],{"class":870},[844,2690,2691,2693,2695],{"class":846,"line":213},[844,2692,2674],{"class":870},[844,2694,1025],{"class":855},[844,2696,2697],{"class":866}," \"not found\"\n",[844,2699,2700,2702],{"class":846,"line":167},[844,2701,2659],{"class":855},[844,2703,2704],{"class":870}," _:\n",[844,2706,2707,2709,2711],{"class":846,"line":13},[844,2708,2674],{"class":870},[844,2710,1025],{"class":855},[844,2712,2713],{"class":866}," \"unknown\"\n",[789,2715,2716,2717,2720],{},"Enums map cleanly too. PHP 8.1's backed enums become an ",[793,2718,2719],{},"Enum"," subclass:",[836,2722,2724],{"className":838,"code":2723,"language":59,"meta":840,"style":840},"enum Status: string\n{\n    case Active = \"active\";\n    case Closed = \"closed\";\n}\necho Status::Active->value;\n",[793,2725,2726,2738,2742,2756,2770,2774],{"__ignoreMap":840},[844,2727,2728,2731,2734,2736],{"class":846,"line":69},[844,2729,2730],{"class":855},"enum",[844,2732,2733],{"class":940}," Status",[844,2735,1204],{"class":855},[844,2737,1207],{"class":855},[844,2739,2740],{"class":846,"line":198},[844,2741,1212],{"class":870},[844,2743,2744,2746,2749,2751,2754],{"class":846,"line":310},[844,2745,2659],{"class":855},[844,2747,2748],{"class":859}," Active",[844,2750,1271],{"class":855},[844,2752,2753],{"class":866}," \"active\"",[844,2755,871],{"class":870},[844,2757,2758,2760,2763,2765,2768],{"class":846,"line":88},[844,2759,2659],{"class":855},[844,2761,2762],{"class":859}," Closed",[844,2764,1271],{"class":855},[844,2766,2767],{"class":866}," \"closed\"",[844,2769,871],{"class":870},[844,2771,2772],{"class":846,"line":213},[844,2773,1238],{"class":870},[844,2775,2776,2778,2780,2783,2786,2788],{"class":846,"line":167},[844,2777,881],{"class":859},[844,2779,2733],{"class":859},[844,2781,2782],{"class":855},"::",[844,2784,2785],{"class":859},"Active",[844,2787,1323],{"class":855},[844,2789,2790],{"class":870},"value;\n",[836,2792,2794],{"className":895,"code":2793,"language":53,"meta":840,"style":840},"from enum import Enum\n\n\nclass Status(Enum):\n    ACTIVE = \"active\"\n    CLOSED = \"closed\"\n\n\nprint(Status.ACTIVE.value)\n",[793,2795,2796,2808,2812,2816,2828,2838,2848,2852,2856],{"__ignoreMap":840},[844,2797,2798,2800,2803,2805],{"class":846,"line":69},[844,2799,2345],{"class":855},[844,2801,2802],{"class":870}," enum ",[844,2804,2351],{"class":855},[844,2806,2807],{"class":870}," Enum\n",[844,2809,2810],{"class":846,"line":198},[844,2811,876],{"emptyLinePlaceholder":11},[844,2813,2814],{"class":846,"line":310},[844,2815,876],{"emptyLinePlaceholder":11},[844,2817,2818,2820,2822,2824,2826],{"class":846,"line":88},[844,2819,2384],{"class":855},[844,2821,2733],{"class":940},[844,2823,911],{"class":870},[844,2825,2719],{"class":940},[844,2827,2523],{"class":870},[844,2829,2830,2833,2835],{"class":846,"line":213},[844,2831,2832],{"class":859},"    ACTIVE",[844,2834,1271],{"class":855},[844,2836,2837],{"class":866}," \"active\"\n",[844,2839,2840,2843,2845],{"class":846,"line":167},[844,2841,2842],{"class":859},"    CLOSED",[844,2844,1271],{"class":855},[844,2846,2847],{"class":866}," \"closed\"\n",[844,2849,2850],{"class":846,"line":13},[844,2851,876],{"emptyLinePlaceholder":11},[844,2853,2854],{"class":846,"line":51},[844,2855,876],{"emptyLinePlaceholder":11},[844,2857,2858,2860,2863,2866],{"class":846,"line":67},[844,2859,908],{"class":859},[844,2861,2862],{"class":870},"(Status.",[844,2864,2865],{"class":859},"ACTIVE",[844,2867,2868],{"class":870},".value)\n",[789,2870,2871,2872,2557,2875,2878],{},"The one place PHP is more ergonomic is null handling. Python has no ",[793,2873,2874],{},"?->",[793,2876,2877],{},"??",", so you write the check out:",[836,2880,2882],{"className":895,"code":2881,"language":53,"meta":840,"style":840},"name = \"guest\"\nif user is not None and user.profile is not None:\n    name = user.profile.name\n",[793,2883,2884,2893,2921],{"__ignoreMap":840},[844,2885,2886,2888,2890],{"class":846,"line":69},[844,2887,1082],{"class":870},[844,2889,1025],{"class":855},[844,2891,2892],{"class":866}," \"guest\"\n",[844,2894,2895,2897,2900,2902,2905,2907,2910,2913,2915,2917,2919],{"class":846,"line":198},[844,2896,1755],{"class":855},[844,2898,2899],{"class":870}," user ",[844,2901,1004],{"class":855},[844,2903,2904],{"class":855}," not",[844,2906,1268],{"class":859},[844,2908,2909],{"class":855}," and",[844,2911,2912],{"class":870}," user.profile ",[844,2914,1004],{"class":855},[844,2916,2904],{"class":855},[844,2918,1268],{"class":859},[844,2920,1281],{"class":870},[844,2922,2923,2926,2928],{"class":846,"line":310},[844,2924,2925],{"class":870},"    name ",[844,2927,1025],{"class":855},[844,2929,2930],{"class":870}," user.profile.name\n",[789,2932,2933,2934,2937,2938,2940,2941,1371,2943,1371,2946,2949,2950,2953],{},"For a simple default, ",[793,2935,2936],{},"value or fallback"," works, but be careful: Python's ",[793,2939,1307],{}," falls back on any falsy value (",[793,2942,1700],{},[793,2944,2945],{},"\"\"",[793,2947,2948],{},"[]","), not just ",[793,2951,2952],{},"None",", so it is not a true null coalescing operator.",[812,2955,2957],{"id":2956},"modules-and-imports","Modules and imports",[789,2959,2960,2961,2964,2965,2968],{},"PHP has namespaces, a ",[793,2962,2963],{},"use"," keyword, and an autoloader that maps class names to files. Python is simpler and more physical: a ",[793,2966,2967],{},".py"," file is a module, a folder of them is a package, and you import by path.",[836,2970,2972],{"className":838,"code":2971,"language":59,"meta":840,"style":840},"\u002F\u002F src\u002FBilling\u002FMoney.php declares: namespace App\\Billing;\nuse App\\Billing\\Money;\n\n$m = new Money(500);\n",[793,2973,2974,2979,2988,2992],{"__ignoreMap":840},[844,2975,2976],{"class":846,"line":69},[844,2977,2978],{"class":849},"\u002F\u002F src\u002FBilling\u002FMoney.php declares: namespace App\\Billing;\n",[844,2980,2981,2983,2986],{"class":846,"line":198},[844,2982,2963],{"class":855},[844,2984,2985],{"class":859}," App\\Billing\\Money",[844,2987,871],{"class":870},[844,2989,2990],{"class":846,"line":310},[844,2991,876],{"emptyLinePlaceholder":11},[844,2993,2994,2997,2999,3002,3004,3006,3009],{"class":846,"line":88},[844,2995,2996],{"class":870},"$m ",[844,2998,1025],{"class":855},[844,3000,3001],{"class":855}," new",[844,3003,2387],{"class":859},[844,3005,911],{"class":870},[844,3007,3008],{"class":859},"500",[844,3010,1674],{"class":870},[836,3012,3014],{"className":895,"code":3013,"language":53,"meta":840,"style":840},"# billing\u002Fmoney.py is the module \"billing.money\"\nfrom billing.money import Money\n\nm = Money(500)\n",[793,3015,3016,3021,3032,3036],{"__ignoreMap":840},[844,3017,3018],{"class":846,"line":69},[844,3019,3020],{"class":849},"# billing\u002Fmoney.py is the module \"billing.money\"\n",[844,3022,3023,3025,3028,3030],{"class":846,"line":198},[844,3024,2345],{"class":855},[844,3026,3027],{"class":870}," billing.money ",[844,3029,2351],{"class":855},[844,3031,2199],{"class":870},[844,3033,3034],{"class":846,"line":310},[844,3035,876],{"emptyLinePlaceholder":11},[844,3037,3038,3041,3043,3046,3048],{"class":846,"line":88},[844,3039,3040],{"class":870},"m ",[844,3042,1025],{"class":855},[844,3044,3045],{"class":870}," Money(",[844,3047,3008],{"class":859},[844,3049,917],{"class":870},[789,3051,3052,3053,3056,3057,3060,3061,1159],{},"There is no autoloader to configure and no ",[793,3054,3055],{},"namespace"," declaration inside the file. The directory structure is the namespace, and ",[793,3058,3059],{},"from package.module import Thing"," is your ",[793,3062,2963],{},[812,3064,3066],{"id":3065},"idioms-and-gotchas","Idioms and gotchas",[789,3068,3069],{},"A few things will trip you up coming from PHP, so here they are up front.",[789,3071,3072,3075,3076,3078,3079,3082,3083,3085],{},[922,3073,3074],{},"Naming."," PEP 8, Python's style guide, wants ",[793,3077,799],{}," for functions and variables and ",[793,3080,3081],{},"PascalCase"," for classes. After years of PHP's ",[793,3084,803],{}," methods this feels odd, but it is universal in Python.",[789,3087,3088,3091],{},[922,3089,3090],{},"The mutable default argument."," This is the classic trap. A default value is created once, not per call, so a mutable default is shared across every call:",[836,3093,3095],{"className":895,"code":3094,"language":53,"meta":840,"style":840},"def add_item(item, basket=[]):       # BUG: every call reuses the same list\n    basket.append(item)\n    return basket\n\ndef add_item(item, basket=None):     # fix: default to None, build inside\n    basket = basket if basket is not None else []\n    basket.append(item)\n    return basket\n",[793,3096,3097,3121,3126,3133,3137,3155,3181,3185],{"__ignoreMap":840},[844,3098,3099,3101,3104,3107,3109,3112,3115,3118],{"class":846,"line":69},[844,3100,1248],{"class":855},[844,3102,3103],{"class":940}," add_item",[844,3105,3106],{"class":870},"(item, basket",[844,3108,1025],{"class":855},[844,3110,3111],{"class":870},"[]):       ",[844,3113,3114],{"class":849},"# ",[844,3116,3117],{"class":855},"BUG",[844,3119,3120],{"class":849},": every call reuses the same list\n",[844,3122,3123],{"class":846,"line":198},[844,3124,3125],{"class":870},"    basket.append(item)\n",[844,3127,3128,3130],{"class":846,"line":310},[844,3129,1217],{"class":855},[844,3131,3132],{"class":870}," basket\n",[844,3134,3135],{"class":846,"line":88},[844,3136,876],{"emptyLinePlaceholder":11},[844,3138,3139,3141,3143,3145,3147,3149,3152],{"class":846,"line":213},[844,3140,1248],{"class":855},[844,3142,3103],{"class":940},[844,3144,3106],{"class":870},[844,3146,1025],{"class":855},[844,3148,2952],{"class":859},[844,3150,3151],{"class":870},"):     ",[844,3153,3154],{"class":849},"# fix: default to None, build inside\n",[844,3156,3157,3160,3162,3165,3167,3169,3171,3173,3175,3178],{"class":846,"line":167},[844,3158,3159],{"class":870},"    basket ",[844,3161,1025],{"class":855},[844,3163,3164],{"class":870}," basket ",[844,3166,1755],{"class":855},[844,3168,3164],{"class":870},[844,3170,1004],{"class":855},[844,3172,2904],{"class":855},[844,3174,1268],{"class":859},[844,3176,3177],{"class":855}," else",[844,3179,3180],{"class":870}," []\n",[844,3182,3183],{"class":846,"line":13},[844,3184,3125],{"class":870},[844,3186,3187,3189],{"class":846,"line":51},[844,3188,1217],{"class":855},[844,3190,3132],{"class":870},[789,3192,3193,3201,3202,3204,3205,3207,3208,3210,3211,1159],{},[922,3194,3195,3197,3198,1159],{},[793,3196,1004],{}," versus ",[793,3199,3200],{},"=="," Use ",[793,3203,3200],{}," to compare values (as you would in PHP) and ",[793,3206,1004],{}," only for identity, in practice for ",[793,3209,2952],{}," checks: ",[793,3212,3213],{},"if x is None",[789,3215,3216,3219,3220,1792,3223,1792,3226,3229,3230,3233,3234,1607,3237,1204],{},[922,3217,3218],{},"Errors."," It is ",[793,3221,3222],{},"try",[793,3224,3225],{},"except",[793,3227,3228],{},"finally",", not ",[793,3231,3232],{},"catch",", and you ",[793,3235,3236],{},"raise",[793,3238,3239],{},"throw",[836,3241,3243],{"className":838,"code":3242,"language":59,"meta":840,"style":840},"try {\n    risky();\n} catch (RuntimeException $e) {\n    log($e->getMessage());\n} finally {\n    cleanup();\n}\n",[793,3244,3245,3252,3260,3276,3292,3300,3307],{"__ignoreMap":840},[844,3246,3247,3249],{"class":846,"line":69},[844,3248,3222],{"class":855},[844,3250,3251],{"class":870}," {\n",[844,3253,3254,3257],{"class":846,"line":198},[844,3255,3256],{"class":940},"    risky",[844,3258,3259],{"class":870},"();\n",[844,3261,3262,3265,3267,3270,3273],{"class":846,"line":310},[844,3263,3264],{"class":870},"} ",[844,3266,3232],{"class":855},[844,3268,3269],{"class":870}," (",[844,3271,3272],{"class":859},"RuntimeException",[844,3274,3275],{"class":870}," $e) {\n",[844,3277,3278,3281,3284,3286,3289],{"class":846,"line":88},[844,3279,3280],{"class":859},"    log",[844,3282,3283],{"class":870},"($e",[844,3285,1323],{"class":855},[844,3287,3288],{"class":940},"getMessage",[844,3290,3291],{"class":870},"());\n",[844,3293,3294,3296,3298],{"class":846,"line":213},[844,3295,3264],{"class":870},[844,3297,3228],{"class":855},[844,3299,3251],{"class":870},[844,3301,3302,3305],{"class":846,"line":167},[844,3303,3304],{"class":940},"    cleanup",[844,3306,3259],{"class":870},[844,3308,3309],{"class":846,"line":13},[844,3310,1238],{"class":870},[836,3312,3314],{"className":895,"code":3313,"language":53,"meta":840,"style":840},"try:\n    risky()\nexcept RuntimeError as e:\n    log(str(e))\nfinally:\n    cleanup()\n",[793,3315,3316,3322,3327,3340,3350,3356],{"__ignoreMap":840},[844,3317,3318,3320],{"class":846,"line":69},[844,3319,3222],{"class":855},[844,3321,1281],{"class":870},[844,3323,3324],{"class":846,"line":198},[844,3325,3326],{"class":870},"    risky()\n",[844,3328,3329,3331,3334,3337],{"class":846,"line":310},[844,3330,3225],{"class":855},[844,3332,3333],{"class":859}," RuntimeError",[844,3335,3336],{"class":855}," as",[844,3338,3339],{"class":870}," e:\n",[844,3341,3342,3345,3347],{"class":846,"line":88},[844,3343,3344],{"class":870},"    log(",[844,3346,1256],{"class":859},[844,3348,3349],{"class":870},"(e))\n",[844,3351,3352,3354],{"class":846,"line":213},[844,3353,3228],{"class":855},[844,3355,1281],{"class":870},[844,3357,3358],{"class":846,"line":167},[844,3359,3360],{"class":870},"    cleanup()\n",[789,3362,3363,3366,3367,1371,3369,1144,3372,1159],{},[922,3364,3365],{},"Batteries included."," Python's standard library is broad. Reading JSON, handling dates, building paths, making HTTP requests, much of what you might pull a Composer package for is already there in modules like ",[793,3368,737],{},[793,3370,3371],{},"datetime",[793,3373,3374],{},"pathlib",[789,3376,3377],{},"You already think in types, objects, immutability, enums, and pattern matching. Python just asks you to spell them with indentation and underscores. The fastest way to make it stick is to build something small and real, and the standard library makes that genuinely quick.",[3379,3380,3382],"note",{"label":3381},"Go further",[789,3383,3384,3385,3387],{},"Put the new language to work: the ",[806,3386,809],{"href":808}," builds and deploys real Python functions as Docker container images, with everything tested locally first.",[3389,3390,3391],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .s-3mD, html code.shiki .s-3mD{--shiki-default:#FFAB70;--shiki-dark:#FFAB70}",{"title":840,"searchDepth":198,"depth":198,"links":3393},[3394,3395,3396,3397,3398,3399,3400,3401,3402],{"id":814,"depth":198,"text":815},{"id":1008,"depth":198,"text":1009},{"id":1162,"depth":198,"text":1163},{"id":1335,"depth":198,"text":1336},{"id":1804,"depth":198,"text":1805},{"id":2175,"depth":198,"text":2176},{"id":2564,"depth":198,"text":2565},{"id":2956,"depth":198,"text":2957},{"id":3065,"depth":198,"text":3066},{"id":51,"name":52,"slug":53,"hue":54},"If you write modern PHP, you already think in the right shapes: types, classes, enums, match, named arguments, immutability. Python has all of those too, it just spells them differently, with indentation instead of braces and snake_case instead of camelCase. This guide maps what you know onto Python so you can start reading and writing it quickly, without relearning how to program. If you followed my AWS Lambda series, those handlers were Python; this is the language behind them.","md",{},{"title":46,"description":3404},"posts\u002Fpython-for-php-developers",[53,59],[3411,3412],{"name":52,"slug":53},{"name":58,"slug":59},"S8vHzoOIjVW12bWNZyslX1Ctpw7LxhDeN7gNa6l2o44",1781531463925]