If you’ve ever felt like type hints in Python are getting…out of hand, you’re not alone. In this talk, Carlton Gibson (Django Steering Council) breaks down a real tension: Python was designed to stay dynamic, and type hints were never meant to be mandatory. But today, many teams feel pressure to add them anyway. Consider #Django, for example: • It’s built on dynamic patterns (introspection, minimal boilerplate, etc.). • Static typing often can’t fully represent those patterns. • Adding types can increase complexity without real safety gains. • Sometimes you’re just repeating yourself to satisfy the type checker. So what’s the alternative? Don’t force typing where it doesn’t fit. Keep Python dynamic – and add types where they actually bring value. The key takeaway: Instead of rewriting frameworks like Django, build typed layers on top – keeping flexibility while adding structure where needed. Don’t think “types vs. no types.” Think about using the right tool in the right place. ▶️ Watch the full talk: https://lnkd.in/eptmtpHj #Python #Django #TypeHints #StaticTyping #WebDevelopment
More Relevant Posts
-
🚀 Master Python Strings: Beyond the Basics! Ever feel like you're only using upper() and lower()? Python’s string library is massive, and knowing the right method can save you lines of code and hours of debugging. 🐍 The table below is a fantastic "at-a-glance" guide, but did you know about these powerful extras? 💡 Pro-Tips for your next script: The Joiner: .join() is the cleanest way to turn a list into a string. Forget manual loops! Global Matching: Use .casefold() instead of .lower() for internationalized text—it’s much more robust for non-English characters. The Cleaner: While the chart shows .strip(), don't forget .rsplit() if you only need to break down a string from the end. Input Validation: .isalnum() is your best friend for checking if a username or password contains only letters and numbers. Common Catch: Notice len() in the list? It’s actually a built-in function, not a method! You call it like len(text), not text.len(). Also, module is a general programming concept, not a string method. #Python #CodingTips #DataScience #WebDevelopment #PythonProgramming #CleanCode #SoftwareEngineering #LearningToCode
To view or add a comment, sign in
-
-
Day 12/365: Checking If a List Is a Palindrome in Python 🔁 Today I solved a classic problem in Python: checking whether a list is a palindrome or not — using the two‑pointer technique with a for-else loop. 🔍 How this works step by step: I start with a list l that has elements arranged symmetrically. To check if it’s a palindrome, I compare elements from both ends: l[0] with l[-1], l[1] with l[-2], and so on. I only need to go till the middle of the list: range(len(l)//2) Inside the loop: If any pair doesn’t match, I print "list is not palindrome" and use break to exit the loop early. The interesting part is the for-else: The else block runs only if the loop finishes without hitting a break. That means all pairs matched, so I print "list is palindrome". 💡 What I learned: How to use the two‑pointer technique to compare elements from start and end efficiently. How Python’s for-else works — the else is tied to the loop, not the if. Why we only need to iterate till the middle of the list for palindrome checking. How the same logic can be reused for: checking if a string is a palindrome, validating symmetric data in lists and arrays. Day 12 done ✅ 353 more to go. If you have ideas like: checking palindromes while ignoring cases/spaces in strings, handling mixed data types in lists, or checking palindromes in other data structures, drop them in the comments — I’d love to try them next. #100DaysOfCode #365DaysOfCode #Python #LogicBuilding #TwoPointers #Lists #CodingJourney #LearnInPublic #AspiringDeveloper
To view or add a comment, sign in
-
-
Day 11/365: Finding the Smallest & Second Smallest Element in a List 🔍📉 Today I worked on a classic list problem in Python: finding the smallest and second smallest elements in a list, along with their indexes — without sorting the list. What this code does step by step: I start with a list L containing different numbers. I initialize two variables: smallest and s_smallest (second smallest) with a value larger than most of the elements in the list. I also track their positions using smallest_index and second_smallest_index. Then I loop through the list using indexes: If the current element is less than or equal to smallest, I: move the current smallest to s_smallest, update smallest with the new value, and update both indexes accordingly. Else if the current element is only smaller than s_smallest, I update just the second smallest and its index. In the end, I print both the smallest and second smallest values with their positions in the list. What I learned from this exercise: How to track not just one, but two minimum values in a single pass through the list. How important it is to maintain both the value and the index while updating. How careful initialization of variables (like smallest and s_smallest) affects the correctness of the logic. How this pattern can be extended to find top-k smallest or largest elements efficiently without sorting. Day 11 done ✅ 354 more to go. If you have ideas like handling edge cases (e.g., duplicates, negative numbers, very large lists) or finding the k-th smallest element, send them my way — I’d love to build on this next. #100DaysOfCode #365DaysOfCode #Python #LogicBuilding #Lists #Indexing #CodingJourney #LearnInPublic #AspiringDeveloper
To view or add a comment, sign in
-
-
Python scope is one of those topics that separates developers who debug fast from those who don't. The language gives you no warning when a variable resolves to an unexpected value. It simply executes, returns a result, and moves on. Tracking down the source of that behaviour - without a solid mental model of how Python resolves names - can cost hours. The LEGB rule isn't complicated. But it's rarely taught with the depth it deserves. I wrote a free guide to change that: → How Python's name resolution actually works under the hood → The LEGB lookup chain with concrete, practical examples → Enclosing scopes and closure behaviour explained clearly → When global and nonlocal are appropriate - and when they signal a design problem → The scope patterns most likely to introduce silent bugs in real codebases Download it free: https://lnkd.in/djp6HJdD #Python #SoftwareEngineering #PythonDevelopment #BackendDevelopment
To view or add a comment, sign in
-
If your Python scripts are making 50 API calls, synchronous code spends most of its time waiting around doing absolutely nothing. Suresh Vina has written an intro to async Python using a simple analogy: boiling a kettle and making toast at the same time. Sync code does one, then the other. Async runs both concurrently. Same two tasks: 5 seconds sync, 3 seconds async. It’s not a big deal when making breakfast. But scale that concept across dozens of API calls and the difference adds up. The Infrahub Python SDK supports both sync and async natively. Switching between them is simple. Suresh walks through the core concepts, shows side-by-side code examples, and builds up to running the same operation across multiple sites concurrently. If async Python has been sitting on your "I should learn that someday" list, now’s your chance to *get up to speed*. (See what we did there? 😉) Link in comments 👇
To view or add a comment, sign in
-
-
One thing that significantly improved my Python code quality: Static analysis is not optional at scale. For a long time, I relied on code reviews to catch issues. Eventually, I realized something: 👉 Humans are bad at consistently spotting patterns. 👉 Tools are not. That’s where static analysis changed everything. Without running the code, these tools analyze your source and detect: bugs code smells complexity issues type inconsistencies All before production The combination that worked best for me: Ruff → fast linting and code quality Replaces multiple tools (flake8, isort, etc.) and runs extremely fast Mypy → type checking Uses type hints to catch bugs before runtime, bringing discipline to Python’s dynamic nature Radon → complexity analysis Measures cyclomatic complexity and highlights functions that are hard to maintain. #Python #StaticAnalysis #BackendEngineering #Django #CleanCode #SoftwareEngineering #DevOps
To view or add a comment, sign in
-
-
Day 9 of #30DaysOfPython ✅ Today I stopped letting my code crash. Exception handling. Here's what my scripts looked like before today. You type the wrong thing, Python throws a wall of red text at you, the whole program dies, and you sit there feeling personally attacked. Today I learned how to catch those errors before they explode. Wrap the risky code in a try block, tell Python exactly what to do if something goes wrong in the except block, and your program keeps running like nothing happened. The moment that sold me: I wrote a simple division script. Without exception handling, typing 0 as the divisor crashed everything with a ZeroDivisionError. With a try/except block, it just printed "hey, you can't divide by zero" and moved on. Same error. Completely different experience. The thing that tripped me up: I was writing bare except blocks — catching every possible error without specifying which one. My mentor's voice in my head (okay, it was a Stack Overflow answer) told me that's bad practice. If you catch everything, you also catch errors you didn't know existed and hide real bugs from yourself. Always name the exception. except ValueError, except FileNotFoundError, except ZeroDivisionError. Be specific. The finally block was the other thing that clicked today. Code inside finally runs no matter what — whether the try succeeded or the except caught something. Perfect for cleanup tasks. Closing a connection. Printing a summary. Saying goodbye gracefully. What I covered today: try / except — the basic safety net Catching specific exceptions by name else block — runs only if no error occurred finally block — runs always, no matter what Raising your own errors with raise Today's mini project: a safe calculator. It handles division by zero, invalid inputs, and unknown operations — all without crashing once. Day 9 done. My code finally fails gracefully. 🎯 👇 What's the most unexpected error you've ever had to catch in Python? I want to know what's waiting for me further down this road! #Python #30DaysOfPython #ExceptionHandling #BuildInPublic #CleanCode
To view or add a comment, sign in
-
-
Today’s Python lesson was one of those “ohhh, so this is why programming feels so organized” moments. 🐍 Day 05 of my #30DaysOfPython journey was all about lists, and honestly, this topic felt like the first real step toward writing cleaner, more useful code. A list in Python is an ordered and mutable collection. It can hold different data types, and yes, it can even be empty. Here’s what I explored today: 1. Creating lists with [] and list() 2. Checking length with len() 3. Accessing items through indexing, slicing, and unpacking 4. Using in to check whether an item exists 5. Adding items with append() and insert() 6. Removing items with remove(), pop(), del, and clear() 7. Copying lists with copy() 8. Joining lists using + and extend() 9. Counting and locating items with count() and index() 10. Reversing with reverse() 11. Sorting with sort() and sorted() They are not just containers for values — they are one of the most practical ways to organize, update, combine, and manage data in Python. The fact that you can add, remove, slice, copy, reverse, and sort them makes them feel like a real data-handling tool rather than just a basic collection. Today reminded me that lists are one of the most useful structures in Python because they let you work with data in a very dynamic way. One more day, one more topic, one more layer of understanding. Github Link - https://lnkd.in/gUt9EfWs #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
🔤 DAY 2/30: I CAN NOW MANIPULATE TEXT LIKE A PRO Today I learned string methods in Python - functions that transform text. 📚 WHAT I LEARNED: • .strip() - remove extra spaces (clean user input) • .upper() / .lower() - change case instantly • String slicing - grab specific parts of text [start:end] • .replace() - swap words in seconds 🛠️ PROJECT: Username Validator A program that: 1. Takes any messy username input 2. Cleans it (removes spaces, fixes case) 3. Validates length (5-15 characters) 4. Tells you if it's available 💡 BIGGEST INSIGHT: String methods don't change the original - they create a NEW string. That's why you need to save them: `name = name.strip()` 🐛 BUG I FIXED: Forgot to save the cleaned string - kept getting original. Now I know: methods RETURN values, they don't modify in place. 📂 DAY 2 CODE: https://lnkd.in/gvg2Rh6N 28 days to go. Getting stronger every day. #Python #30DaysOfCode #CodingJourney #LearnToCode
To view or add a comment, sign in
-
Metaclasses in Python-The Hidden Power Behind Classes Most developers know that objects are created from classes. But here’s something many don’t realize. 👉 Classes themselves are created by something called a Metaclass 🧠 What is a Metaclass? A metaclass is simply: ➡️ A class that defines how other classes are created By default, Python uses: type Yes, the same type() you use to check data types! Let’s Break It Down When you write: class MyClass: pass Python actually does this behind the scenes: MyClass = type('MyClass', (), {}) 👉 That means: type is the default metaclass It constructs your class dynamically. Why Use Metaclasses? Metaclasses are powerful but should be used carefully . They are useful when you want to: ✅ Enforce coding standards across classes ✅ Automatically modify class attributes ✅ Register classes (plugin systems) ✅ Build frameworks (like Django ORM internally) Final Thought Metaclasses are advanced Python magic . They give you control over class creation itself — something most developers never touch. But once you understand them… You start thinking like a framework developer. Have you ever used metaclasses in a real project? Or is this your first time exploring them? #Python #AdvancedPython #BackendDevelopment #Django #SoftwareEngineering #LearnToCode
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
1000% this. Part of the problem is when you put a nominal type checker on a package you feel immense pressure to get it to zero output and to do that you either need to over type or put in a bunch of ignores. If you need your program to be type safe don't use python! Thats what a compiler is for.