Two lines of Python. Same result. Very different design. A method and a property can look almost interchangeable, but they communicate very different things about your code: cost, safety, and intent. Get that choice wrong, and you end up hiding work, I/O, or even async behavior behind what looks like a simple attribute access. In today’s video, I walk through clear, practical guidelines for deciding when something should be a property and when it should be a method. I’ll look at derived state, setters, Protocols, and why async properties are usually a design smell, even though Python technically allows them. 👉 Watch the full breakdown here: https://lnkd.in/eTHn7Rks. #python #softwaredesign #cleancode #objectoriented #apiDesign #developers
ArjanCodes’ Post
More Relevant Posts
-
Two lines of Python. Same result. Very different design. A method and a property can look almost interchangeable, but they communicate very different things about your code: cost, safety, and intent. Get that choice wrong, and you end up hiding work, I/O, or even async behavior behind what looks like a simple attribute access. In today’s video, I walk through clear, practical guidelines for deciding when something should be a property and when it should be a method. I’ll look at derived state, setters, Protocols, and why async properties are usually a design smell, even though Python technically allows them. 👉 Watch the full breakdown here: https://lnkd.in/eyXC6xyM. #python #softwaredesign #cleancode #objectoriented #apiDesign #developers
To view or add a comment, sign in
-
-
🧩 A Python Question That Traps Even Experienced Developers What will this print? 👇 a = 1000 b = 1000 print(a == b, a is b) Many people guess: True True ❌ Correct answer: True False ✅ Here’s why 👇 🔹 == compares values It checks whether the contents are equal. 1000 == 1000 → ✔ True 🔹 is compares object identity (memory location) It checks whether both variables point to the same object in memory. In this case → ❌ False Even though the values are equal, Python typically creates separate objects for larger integers. 💡 Interesting Fact: Python caches small integers from -5 to 256. That’s why: a = 10 b = 10 print(a is b) # True 🎯 Lesson: ✔ Use == to compare values ✔ Use is only for identity checks (especially with None) Small concept. Big interview impact. What answer did you guess first? 👀 #Python #Programming #SoftwareEngineering #LearnInPublic #100DaysOfCode #WomenInTech #Developers #TechStudents #CodingJourney
To view or add a comment, sign in
-
🚀 Python Tip Day 5 – List Comprehension (Write Cleaner Code) Most developers write loops like this: squares = [] for i in range(5): squares.append(i * i) But Python gives you a shorter and cleaner way 👇 squares = [i * i for i in range(5)] 💡 Why this matters: Less code More readable Faster to write Widely used in real projects 🧠 What’s happening? [expression for item in iterable] 👉 For each number in range(5), we calculate i * i 🛠 Mini Practice: Create a list of even numbers from 1 to 10 using list comprehension. Simple tricks like this can make your code look more professional instantly. #Python #PythonTips #Coding #Developers #LearnPython #SoftwareDevelopment
To view or add a comment, sign in
-
Still writing count = count + 1? There’s a shorter way. 📈 count += 1 does the same thing — and it’s what you’ll see in almost every Python codebase. I wrote a short beginner’s guide that covers: ✅ What “update a variable” means (same name on both sides of =) ✅ The short form: +=, -=, *=, /=, %= ✅ Why += 1 is the standard for counting ✅ Bitwise compound: &=, |=, ^=, <<=, >>= ✅ Summary table + practice problems with answers ✅ Why the short form is cleaner and less error‑prone ~5 min read. Straight to the point. https://lnkd.in/gV3TBusi #Python #Programming #Coding #Beginners #LearnToCode #AugmentedAssignment #Operators #Tech #SoftwareDevelopment #CodingTips
To view or add a comment, sign in
-
-
Python Tip — Read & Write Files the Right Way Still using open() without a context manager? Modern Python gives you a safer, cleaner way: Always use `with open(...) as f: Why? - Automatically closes the file - Prevents memory leaks - Cleaner, more readable code - Production-safe habit Small habit. Big impact. File handling isn’t just about reading and writing, it’s about writing code you can trust. FOLLOW FOR MORE PYTHON TIPS & INSIGHTS. #Python #Programming #CleanCode #Backend #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Formatting Dates and Times (strftime) (Python) The `strftime()` method is used to format date and time objects into strings. It takes a format string as an argument, which specifies how the date and time should be represented. Different format codes are available to represent various components of the date and time. This is crucial for presenting dates and times in a user-friendly or application-specific format. #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
🔥 𝐖𝐡𝐚𝐭’𝐬 𝐭𝐡𝐞 𝐫𝐞𝐚𝐥 𝐝𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐜𝐞 𝐡𝐞𝐫𝐞? Same logic. Same condition. Same output. But one tiny indentation mistake… and your code breaks. 💥 In Python, indentation is not styling — it’s syntax. Clean code isn’t about writing more. It’s about writing correctly. 👉 Attention to detail separates beginners from professionals. 👉 What’s the exact difference between them? Drop your answer in the comments 👇 #Python #Programming #CleanCode #Developers #CodingLife #100DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Today I went deeper into Python file handling and it turned out to be more interesting than I expected. What seems simple at first (open(), read(), write()) actually hides subtle behavior: • "w" and "w+" clear the file the moment it’s opened • "r+" allows modification without automatically deleting content • The file pointer silently moves after read/write operations making seek(0) essential • truncate() prevents unexpected leftover data when rewriting shorter content It’s easy to use these functions. It’s harder and more valuable to understand how they behave internally. Worked through practical problems to move from just using file handling to actually understanding it. #Python #learningpython #filehandling
To view or add a comment, sign in
-
-
Debugging got a little less frustrating. Python 3.13 continues the trend of making error messages actually helpful instead of just technical. Now, when you have a typo in a keyword argument or miss a : at the end of a function, the interpreter doesn't just crash — it suggests the fix. Like: 🔘 3.12: SyntaxError: invalid syntax 🔘 3.13: SyntaxError: Missing ':' at the end of the function definition It’s a great example of "Developer Experience" (DX) in the core of a language. Small changes, massive time savings. #python #backend #python #coding #productivity
To view or add a comment, sign in
-
Python provides: ✔ Predefined (Built-in) Functions – Already available Examples: print(), len(), type(), sum() ✔ User-Defined Functions – Created using def keyword def add(a, b): return a + b #Python #Programming #Coding #TechLearning #Functions #DeveloperJourney
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