Python teaches boundaries in the most unexpected ways 😅 Functions really have personalities: Local variables: “I’m only here for this function.” They live inside a function and disappear once it’s done. Global variables “I belong to everyone.” Accessible anywhere in the file… but if you modify them carelessly, your whole program feels it. Nonlocal variables “I’m not global, but I’m not just local either.” They live in an outer function and can only be modified in an inner function if you explicitly declare nonlocal. Here’s what stood out to me: Coming from JavaScript, I was used to closures just working. In JavaScript, if an inner function sees a variable in its outer scope, it can modify it directly. No special keyword. In Python? If you want to modify a variable from an enclosing function, you must explicitly say nonlocal. If you don’t, Python quietly creates a new local variable instead. Same concept. Different philosophy. JavaScript assumes intent. Python requires you to declare it. And that small difference changes how you think about state, structure, and responsibility in your code. Scope isn’t just syntax. It’s architecture. Boundaries matter. In code and in life. #Python #JavaScript #BackendJourney #SoftwareEngineering #WomenInTech
Python vs JavaScript: Variable Scope Boundaries
More Relevant Posts
-
Building in a new language is painful. I felt it myself when I picked Python over Node.js I mainly build in Node.js. But I decided to build a misinformation-detection tool in Python. The first 2 days felt like climbing a mountain — wrong syntax, different patterns, constant confusion. I changed my approach ,first principles over framework habits. Instead of asking "how do I do this in Python like I do in Node?", I asked: "How does this actually work under the hood?" It change how i code and think : => I understood middleware by learning how requests are parsed — not just how to write one. => I stopped copy-pasting patterns and started understanding request cycles and headers => I became faster at picking up new languages If you're stuck in one language or framework, stop learning syntax first. Learn the why behind what the framework is doing for you.
To view or add a comment, sign in
-
-
Day 3 of my Python journey 🐍🚀 Today was all about logic and control flow. Day 3 focused on how Python makes decisions and repeats tasks. Here is a straightforward breakdown of today's concepts and how they compare to my daily TypeScript/JavaScript work: 🔀 Conditionals (If / Elif / Else): Python drops the parentheses () and curly braces {}. It also uses elif instead of else if. It takes a minute to get used to the indentation, but the code reads beautifully, almost like plain English. 🎯 Match Case: This is Python’s exact answer to the JavaScript switch statement! It makes handling multiple specific conditions much neater than writing a giant wall of if/else blocks. 🔁 Loops (For & While): While loops feel very similar to JS, the for loop in Python is wonderfully simplified. Instead of writing out for (let i = 0; i < 10; i++), Python just uses for i in range(10):. It is so much faster to type. 🛑 Break & Continue: The good news? These work exactly the same way they do in JavaScript to stop a loop or skip an iteration entirely. No mental translation needed here! The syntax is really starting to feel natural now. Progress is steady. 📈 #Python #LearningInPublic #SoftwareEngineering #FrontendDev #CodeWithHarry #100DaysOfCode
To view or add a comment, sign in
-
-
Meta built a Python type checker in Rust that makes mypy feel like dial-up. 🔥 Pyrefly already has 5.4k stars, and it's not hard to see why. 𝗛𝗲𝗿𝗲'𝘀 𝘁𝗵𝗲 𝗱𝗲𝗮𝗹: Python's type checking story has always been slow and clunky. Pyrefly rewrites the whole thing from scratch in Rust (92% of the codebase). Giving you a lightning-fast type checker AND a full language server in one tool. Install it with pip, point it at your code, done. 𝗛𝗼𝘄 𝗶𝘁 𝘄𝗼𝗿𝗸𝘀 👉🏽 Three-step pipeline: resolve module exports, convert modules to bindings, solve bindings across your entire project 👉🏽 Uses Type::Var placeholders for recursive and unknown types that resolve later 👉🏽 Module-centric design prioritizing raw speed over fine-grained identifier solving 𝗪𝗵𝗮𝘁 𝘆𝗼𝘂 𝗴𝗲𝘁 👉🏽 Type inference that auto-detects variables and return types without annotations 👉🏽 Flow-sensitive types that track control flow (if/else, isinstance checks) 👉🏽 Incremental checking and parallel processing for large codebases 👉🏽 IDE support for VSCode, Neovim, and Zed out of the box 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗺𝗮𝘁𝘁𝗲𝗿𝘀 👉🏽 Modular Rust crate architecture (pyrefly_util, pyrefly_types, pyrefly_config) 👉🏽 MIT licensed, 153 contributors, 11k+ commits 👉🏽 Browser sandbox so you can try it without installing anything 👉🏽 Biweekly office hours and an active Discord community Python type checking has been an afterthought for too long. A Rust-powered checker that doubles as your language server could finally make it a first-class experience. 𝘈𝘳𝘦 𝘺𝘰𝘶 𝘴𝘵𝘪𝘭𝘭 𝘶𝘴𝘪𝘯𝘨 𝘮𝘺𝘱𝘺, 𝘰𝘳 𝘩𝘢𝘷𝘦 𝘺𝘰𝘶 𝘴𝘸𝘪𝘵𝘤𝘩𝘦𝘥 𝘵𝘰 𝘴𝘰𝘮𝘦𝘵𝘩𝘪𝘯𝘨 𝘧𝘢𝘴𝘵𝘦𝘳? 🔗 Link in comments #python #rust #opensource #meta
To view or add a comment, sign in
-
-
When someone new joins a Python codebase, their first PR tells you everything: single-letter variables, inconsistent imports, functions that return str | None | dict depending on the mood of the day. We have onboarding docs for this, but tooling is what actually enforces it. My default move is three things: Ruff, Pyright, and pre-commit. Ruff with format + lint, fix-on-save, and import sorting. They hit save and the file snaps into shape, which alone kills most style discussions before they ever reach a PR. Then Pyright via Pylance in standard mode. Not strict, because strict in Python is counterproductive unless the whole codebase is designed for it. Standard catches wrong argument types, None-access, and missing returns, the stuff that otherwise shows up as runtime bugs or reviewer nitpicks. Once people see type issues flagged while they're still typing, something clicks and they stop shipping avoidable bugs. That peace of mind is something I never want to go back from. Pre-commit makes all of it non-optional. The same checks run for everyone, every time, before the code even gets pushed. It turns "we should all follow the coding guides" into "you literally can't commit without following them." That's the difference between a convention and a guarantee. With this, reviews actually focus on correctness, design, and edge cases instead of formatting and obvious type errors. You're moving the stuff humans shouldn't be wasting time on to machines that do it better and faster, and you're doing it at the cheapest possible point, before it ever hits a PR. I remember when I first set this up for myself and it felt like someone turned the lights on. I want that for everyone joining the team. What's the first thing you set up when onboarding someone new? #Python #SoftwareEngineering #CodeQuality #DeveloperExperience #DevTools
To view or add a comment, sign in
-
🚀 Just published a Python package to PyPI! pip install human-regex-lib Here's the problem it solves 👇 Every developer has been here: You need to validate an email, extract a phone number, or match a date format. You open a new tab. You Google "regex for email". You copy-paste some cryptic 50-character string and you have no idea if it's even correct. 😅 There had to be a better way. human-regex-lib lets you write regex using plain English keywords. No memorizing. No Googling. No cryptic symbols. Just chain simple words together and it builds the pattern for you behind the scenes. It's fully chainable, zero dependencies, and works on Python 3.8+. Fully open source — the package and all tests are on GitHub. 🔗 PyPI: https://lnkd.in/g_NGyzxN 🔗 GitHub: https://lnkd.in/g6swaa96 If you've ever copy-pasted regex without understanding it — this one's for you. Drop a ⭐ on GitHub if you find it useful, and let me know what patterns you'd want added next! #Python #OpenSource #PyPI #RegularExpressions #100DaysOfCode #BuildInPublic #SoftwareDevelopment
To view or add a comment, sign in
-
-
⁉️ Have you ever actually thought about what __name__ == "__main__" means? Most of us wrote it the first time because a tutorial said so. Today I was structuring a small backend service in Python. Nothing flashy yet, just defining the application entry point. And that familiar line showed up again: ✳️ if __name__ == "__main__": It’s simple, but it solves an important architectural problem. In Python, every file is a module. When you execute a file directly: ✳️ python app.py Python assigns: ✳️ __name__ = "__main__" But when the same file is imported somewhere else: ✳️ import app Now: ✳️ __name__ = "__app__" That difference determines whether certain blocks of code run or stay dormant. Why is that useful? Because it lets you: • Keep runtime logic separate from reusable logic • Prevent accidental execution when modules are imported • Define a clear entry point for your application • Expose objects (like a Flask/FastAPI app instance) without auto-starting the server Without this guard, importing a module could trigger execution unintentionally — which becomes messy in larger systems. It’s one of those small Python conventions that quietly enforces better structure. Not flashy. But foundational. #Python #BackendDevelopment #SoftwareEngineering #Architecture
To view or add a comment, sign in
-
-
📢 532 downloads in 3 days. No marketing. Open Source. No VC money.🚀 Just a Python framework that gets out of your way. We built SynapseKit because debugging LLM apps was taking longer than building them. Too many layers. Too much magic. Too little control over what was actually happening. So we started over. From scratch. ⚡ Async-native. Streaming-first. 2 dependencies. Code you can read on a Monday morning without coffee. What's inside: 🔌 13 LLM providers behind one interface :swap models in one line 🔍 10 retrieval strategies: RAG Fusion, CRAG, Ensemble, Self-Query 🔀 Graph workflows with human-in-the-loop and SSE streaming 🛠️ 16 tools, 12 loaders, 4 memory backends ✅ 540 tests passing No hidden chains. No magic. Just code that does what you think it does. If you're building LLM apps in Python and want something you can actually debug: 📦 pip install synapsekit[openai] 🔗 https://lnkd.in/d2fGSPkX #Python #LLM #RAG #OpenSource #AI #MLEngineering #MachineLearning #Developers #SoftwareEngineering #AgenticAI
To view or add a comment, sign in
-
Python is like that high school ex you run into: you remember the good times, but five minutes in, you're reminded exactly why you moved on. 🐍 After being fully immersed in the TypeScript ecosystem, jumping back into a Python project felt... weird. Going from the safety of strict typing and seamless ESM imports back into the land of manual labor was a wake-up call. Here is the "Welcome Back" package I didn't ask for: The Venv Ritual: Why am I still manually creating and activating virtual environments in 2026? It feels like hand-cranking a car engine just to go to the grocery store. 🛠️ The "Invisible" Packages: That moment when uv list shows the package is there, the interpreter is set correctly, but Python still insists it doesn't exist. Ghosting at its finest. 👻 Manual Everything: Coming from a world where the tooling feels like it has your back, Python's setup feels like it's actively trying to trip you up over a stray .env or a path mismatch. Don't get me wrong, Python is a powerhouse for AI and Data Science, but the developer experience gap is becoming hard to ignore. When you're used to the speed of tools like Bun or the reliability of TS types, those "silly" import errors feel a lot less like a minor bug and a lot more like a tax on your productivity. Has anyone else felt this "syntax shock" lately, or have I just been spoiled by the TS ecosystem? #SoftwareEngineering #Python #TypeScript #WebDevelopment #FullStack #CodingLife
To view or add a comment, sign in
-
-
Day 3 of 10: Python Control Flow & The Quirks of Iteration 🐍🔁 We are onto Day 3 of my Python sprint! Today’s focus from the CodeWithHarry handbook was all about conditional expressions and loops. Moving my backend logic from Node.js to Python is feeling smoother by the day. The pseudo-code nature of it—dropping the curly braces and relying entirely on clean indentation—makes writing complex logic incredibly fast. Here is what stood out to me today: 📌 Streamlined Conditionals: Trading else if for Python's elif. It’s a small syntax shift, but it makes chained conditional blocks read much cleaner. 📌 The range() Function: Iterating with for i in range() is a brilliantly efficient way to generate sequences and handle iterations compared to the traditional for (let i = 0; i < n; i++) we use in JS. 📌 The for...else Construct: This was today's biggest "Aha!" moment. Python actually allows you to attach an else block directly to a for loop. It only executes if the loop exhausts naturally without hitting a break statement. This is an amazing built-in tool for writing search algorithms without needing extra flag variables! All my practice scripts for today are already pushed to the tasks folder in my GitHub repo. Tomorrow, we get into Functions and Recursion! Python devs: How often do you actually use the for...else construct in your production AI or backend code? Is it a daily driver or a niche trick? Let’s discuss! 👇 #Python #SoftwareEngineering #BackendDevelopment #10DayChallenge #CodeWithHarry
To view or add a comment, sign in
-
-
In plain English, "and" and "or" are just connective words. In Python, they are strict gatekeepers. 🧐 ⠀ Confusing them is the easiest way to break the logic of your application. ⠀ Let's look at a real-world example: Going to the cinema. 🍿 ⠀ 🎬 The "Flexible" Approach (OR): Imagine regular entry to a movie. You write: `if has_paper_ticket OR has_digital_app:` ⠀ The `or` operator is chill. It opens the door if *either* condition is met. Did you forget your paper ticket but have your phone? No problem. You're in. ⠀ 🔞 The "Strict" Approach (AND): Now imagine entry to an age-restricted screening (18+). You write: `if has_ticket AND is_over_18:` ⠀ The `and` operator is the strict manager. It demands *both* requirements be met simultaneously. Have a ticket but forgot your ID? You aren't getting in. ⠀ Logical operators aren't just syntax; they define the rules of your digital world. ⠀ Don't accidentally lock your users out (or let the wrong ones in) because you chose the wrong conjunction. ⠀ We turn boring Python documentation into a friendly, 3-minute daily habit. ☕ ⠀ 👇 Subscribe to the website for free: https://lnkd.in/ducXvs-y ⠀ #Python #Logic #CodingTips #SoftwareDevelopment #LearnToCode #PyDaily
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development