Day 338: Leveling Up: Print vs. Logging 📊 Why I Stopped Using print() for Debugging When I started coding, I used print("Here 1"), print("Here 2") to find bugs. It worked, but it was messy. In production environments, you can't stare at the console. You need logging. The logging module lets you leave "breadcrumbs" in your code. You can save them to a file to see exactly what happened at 3:00 AM when your script crashed. 👉 A Professional Setup: import logging # Configure it to save to a file logging.basicConfig(filename='app.log', level=logging.INFO) def process_payment(amount): logging.info(f"Attempting to process ${amount}...") # Logic here... logging.error("Payment Gateway Timeout!") # This gets saved for later inspection process_payment(50) challenge: Go back to an old script and replace your print statements with logging.info(). It’s a game changer. #Python #DevOps #SoftwareEngineering #BestPractices
Logging Over Print for Debugging in Python
More Relevant Posts
-
mise: Because managing dev tools shouldn’t require a PhD in shell scripting. 🔥 If you ever found yourself explaining to a colleague again how to install the “right version” of Node, Python, Terraform, or literally anything else… you need to meet me, I mean mise do not meet me not a wise choice. Think of it as: - asdf, but not broken - direnv’s chill cousin - Makefiles, but understandable by humans All mashed together into one Rust-powered CLI. When I first stumbled on mise (yes, I responsibly avoided instagram-scrolling and found something actually useful), it actually simplified my life: • One config to rule all tool versions • Seamless per-project env vars without cursed shell hacks • Getting tasks and tools working in harmony (bye bye Docker+scripts juggling) This means I spend less time explaining “it works on my machine” and more time shipping code. Real talk: Before mise, tooling felt like a weird mix of tribal knowledge and hope. With mise? I drop a mise.toml in a repo and magically everyone gets the right versions + env + tasks. It’s perfect for: • Monorepos with many languages • Teams tired of “install this 8 step script first” • Anyone who believes developer experience matters #devtools #productivity #softwareengineering #opensource #rust #buildinpublic #mise #jdx https://mise.jdx.dev
To view or add a comment, sign in
-
"IF-ELSE" CHAINS ARE A CODE SMELL. 👃 One of the biggest leaps from "Junior" to "Senior" engineering is realizing that if statements are often a sign of missing architecture. In many of my projects, I frequently deal with logic that needs to change behavior based on context. • Sometimes we need the Shortest Path (Dijkstra). • Sometimes we need the Fastest Calculation (Greedy Best-First). • Sometimes we need to avoid specific obstacles (Custom A*). The novice approach is a massive switch statement or a 50-line if-else block. The engineering approach is the Strategy Pattern. By defining a common Interface (e.g., IRouteFinder), we can inject the specific algorithm into the solver at runtime. The solver doesn't care how the path is found, only that it is found. The C++ Optimization: Classically, we do this with Virtual Functions (Runtime Polymorphism). But in modern C++ (17+), I’ve been experimenting with std::variant and std::visit. This allows us to achieve similar "swappable logic" but often with better cache locality and no v-table overhead. It’s a technique I see often in High-Frequency Trading systems to keep things "static" where possible. I’m currently refactoring my personal Python project to use this pattern for its scoring engine, swapping "League Rules" without touching the core match logic. What’s your favorite Design Pattern to clean up messy logic? Strategy? Observer? Factory? #SoftwareArchitecture #DesignPatterns #Cplusplus #Python #CleanCode #Refactoring
To view or add a comment, sign in
-
System Design – Expectation vs Reality Expectation: “Bro, it’s just one simple API" Reality: Load balancer because traffic might come🥴 Cache because the database will cry😭 Queue because async is “optional” until it’s not😌 Retry logic because networks have emotions🙂 Monitoring because production only breaks at 2 AM😵 And suddenly… system design round unlocked😫 At this point, you’re not coding — you’re negotiating with scale, failures, and future-you. Lesson learned: But design like things will scale and something will break. Still learning. Still building. Still redesigning. #SystemDesign #BackendDeveloper #DeveloperLife #SoftwareEngineering #Python #Django #FastApi
To view or add a comment, sign in
-
Focused on improving code quality today while building a small system health script. ✔ Organized the code into clear functions ✔ Added basic exception handling (try/except) ✔ Improved variable naming and readability ✔ Ensured the script does not crash on common errors Building strong foundations for automation and production-ready scripting. Shubham LondheTrainWithShubham #PythonForDevOps #TrainWithShubham #DevOpsKaJosh#Python #DevOps #Automation #CleanCode #LearningInPublic #Scripting
To view or add a comment, sign in
-
-
🚀 Tired of manual API checks? I built a tool for that. As developers, we spend too much time debugging connections and checking if endpoints are alive. I wanted something lightweight, Pythonic, and actually helpful — so I built it. Introducing integration-smoke-test 🐍 It’s a Python library for quick integration smoke tests. It doesn’t just tell you that something failed — it tells you why (network error, DNS issue, timeout) and suggests what to do next. Key features: ✅ Instant connectivity checks ✅ Structured diagnostics (latency, error category, status) ✅ Actionable hints for faster debugging 📸 Example usage attached 👇 Repo link in comments #Python #OpenSource #DevTools #BackendDevelopment #APITesting #Engineering
To view or add a comment, sign in
-
-
I refactored some business logic, cleaned up the code… and accidentally changed what the software does. In this video, I go through the mistakes I made, why they’re so easy to introduce during refactoring, and why passing tests and good coverage don’t automatically mean your logic is correct. Especially when business rules are involved, assumptions sneak in fast. This one is less about a specific bug and more about a reality of software engineering: there often is no single ground truth. Not in the code, not in the tests, and not in the requirements. If you’ve ever felt slightly uneasy after a "successful" refactor, this will probably look familiar. Watch the video here: https://lnkd.in/ej-VFrz4 #softwareengineering #refactoring #cleanCode #python #testing #softwareDesign #programming #developers
To view or add a comment, sign in
-
-
🚀 Day 50 of #100DaysOfCode 🎯 (Halfway there! 🔥) Today’s challenge was an array + dynamic programming twist problem — 📊 LeetCode: Maximum Product Subarray 📌 Problem Summary Given an integer array, find the contiguous subarray (containing at least one number) that has the largest product. At first glance, it looks similar to maximum subarray sum… but the presence of negative numbers changes everything ⚠️ 🧠 My Approach: Tracking Max & Min Products The key insight 👇 A negative number can turn the smallest product into the largest. So instead of tracking only the maximum, I tracked: ✅ max product ending at current index ✅ min product ending at current index At each step: Compute new max using (current, max*current, min*current) Compute new min similarly Update the global result This keeps everything in one pass 🚀 ⚙️ Complexity Analysis ⏱ Time: O(n) 💾 Space: O(1) Efficient and clean ✨ 🔥 Key Learning Negative numbers can flip the problem logic Some DP problems don’t need arrays — just smart state tracking Always think in terms of states, not just values ✅ Solution accepted with strong runtime performance Another powerful array pattern mastered 💪 Onward from Day 50 — the grind continues 🚀🔥 #100DaysOfCode #LeetCode #Java #DynamicProgramming #Arrays #ProblemSolving #CodingJourney #DSA
To view or add a comment, sign in
-
-
Why every developer should use a .env file If you’re still hard-coding secrets like API keys, database passwords, or debug settings in your code, it’s time to stop. The .env file helps you: ✅ Keep sensitive data secure ✅ Separate configuration from code ✅ Easily switch between development, testing, and production environments ✅ Avoid accidentally exposing secrets on GitHub In Python, tools like os.environ and libraries such as python-dotenv make working with environment variables simple and clean. Best practice: ✔ Add .env to .gitignore ✔ Share a .env.example instead ✔ Keep your code portable and secure Small habit. Big impact. #Python #SoftwareDevelopment #BestPractices #DevTips #EnvironmentVariables
To view or add a comment, sign in
-
𝘞𝘢𝘯𝘵 𝘵𝘰 𝘮𝘢𝘬𝘦 𝘺𝘰𝘶𝘳 𝘈𝘗𝘐𝘴 𝘣𝘶𝘭𝘭𝘦𝘵𝘱𝘳𝘰𝘰𝘧 𝘢𝘯𝘥 𝘢𝘤𝘵𝘶𝘢𝘭𝘭𝘺 𝘪𝘮𝘱𝘳𝘦𝘴𝘴 𝘺𝘰𝘶𝘳 𝘵𝘦𝘢𝘮? 𝘐 𝘭𝘦𝘢𝘳𝘯𝘦𝘥 𝘵𝘩𝘪𝘴 𝘵𝘩𝘦 𝘩𝘢𝘳𝘥 𝘸𝘢𝘺 — 3 𝘱𝘳𝘰𝘥𝘶𝘤𝘵𝘪𝘰𝘯 𝘰𝘶𝘵𝘢𝘨𝘦𝘴 𝘵𝘢𝘶𝘨𝘩𝘵 𝘮𝘦 𝘵𝘩𝘦 𝘰𝘯𝘦 𝘵𝘩𝘪𝘯𝘨 𝘯𝘰 𝘰𝘯𝘦 𝘳𝘦𝘢𝘭𝘭𝘺 𝘵𝘢𝘭𝘬𝘴 𝘢𝘣𝘰𝘶𝘵: 👉 𝘭𝘰𝘢𝘥 𝘵𝘦𝘴𝘵𝘪𝘯𝘨 𝘦𝘢𝘳𝘭𝘺, 𝘢𝘯𝘥 𝘥𝘰𝘪𝘯𝘨 𝘪𝘵 𝘳𝘪𝘨𝘩𝘵. 𝘐 𝘱𝘶𝘵 𝘵𝘰𝘨𝘦𝘵𝘩𝘦𝘳 𝘢 𝘩𝘢𝘯𝘥𝘴-𝘰𝘯 𝘨𝘶𝘪𝘥𝘦 𝘦𝘹𝘱𝘭𝘢𝘪𝘯𝘪𝘯𝘨 𝘵𝘩𝘦 𝘮𝘪𝘴𝘵𝘢𝘬𝘦 𝘐 𝘬𝘦𝘱𝘵 𝘮𝘢𝘬𝘪𝘯𝘨 — 𝘢𝘯𝘥 𝘩𝘰𝘸 𝘐 𝘧𝘪𝘯𝘢𝘭𝘭𝘺 𝘧𝘪𝘹𝘦𝘥 𝘪𝘵 𝘶𝘴𝘪𝘯𝘨 𝘓𝘰𝘤𝘶𝘴𝘵 𝘵𝘰 𝘤𝘢𝘵𝘤𝘩 𝘪𝘴𝘴𝘶𝘦𝘴 𝘣𝘦𝘧𝘰𝘳𝘦 𝘶𝘴𝘦𝘳𝘴 𝘦𝘷𝘦𝘳 𝘴𝘦𝘦 𝘵𝘩𝘦𝘮. 📖 𝘙𝘦𝘢𝘥 𝘵𝘩𝘦 𝘩𝘢𝘯𝘥𝘴-𝘰𝘯 𝘵𝘶𝘵𝘰𝘳𝘪𝘢𝘭 𝘩𝘦𝘳𝘦: 👉 𝘩𝘵𝘵𝘱𝘴://𝘭𝘯𝘬𝘥.𝘪𝘯/𝘥𝘊𝘮3𝘑𝘏𝘚𝘱 👉 𝘎𝘪𝘵𝘩𝘶𝘣 𝘳𝘦𝘱𝘰𝘴𝘪𝘵𝘰𝘳𝘺 𝘪𝘴 𝘪𝘯 𝘵𝘩𝘦 𝘤𝘰𝘮𝘮𝘦𝘯𝘵𝘴 👇 𝘐 𝘣𝘶𝘪𝘭𝘥 𝘢𝘯𝘥 𝘳𝘦𝘷𝘪𝘦𝘸 𝘈𝘐 & 𝘥𝘪𝘴𝘵𝘳𝘪𝘣𝘶𝘵𝘦𝘥 𝘴𝘺𝘴𝘵𝘦𝘮𝘴 𝘵𝘩𝘢𝘵 𝘢𝘤𝘵𝘶𝘢𝘭𝘭𝘺 𝘴𝘶𝘳𝘷𝘪𝘷𝘦 𝘱𝘳𝘰𝘥𝘶𝘤𝘵𝘪𝘰𝘯. #LoadTesting #Locust #Python #DevOps #PerformanceTesting #SoftwareEngineering #API #BackendDevelopment #ProductionReady
To view or add a comment, sign in
-
✏️ DSA Diary Day 14/100 📊➗: Solving LeetCode’s “Maximum Dot Product of Two Subsequences” 🚀✨ Today I worked on a Dynamic Programming + Recursion + Optimization problem on LeetCode 🔥👇 👉 Maximum Dot Product of Two Subsequences This problem is a great example of how DP helps handle complex choices efficiently 🧠💡 🔹 My Approach 🛠️🧠 I used Recursion + Memoization (Top-Down DP) 🔁👇 🔸 Step 1: Define DP State 📌 dp(i, j) = Maximum dot product using elements from nums1[i…] elements from nums2[j…] 🔸 Step 2: Choices at Each Step 🔍 At every (i, j) position, we have 4 options: 1️⃣ Take both elements & continue nums1[i] * nums2[j] + dp(i+1, j+1) 2️⃣ Take both & stop here nums1[i] * nums2[j] 3️⃣ Skip nums1[i] dp(i+1, j) 4️⃣ Skip nums2[j] dp(i, j+1) We take the maximum of all these options 🔝✨ 🔸 Step 3: Memoization 🧠 To avoid recomputation, I used a 2D memo array This reduces time complexity from exponential → O(n*m) 🚀 🔸 Why NEG_INF? ⚠️ To ensure at least one pair is selected, I returned a very small value when indices go out of bounds. 🔹 Key Learnings 📚✨ ✅ DP is perfect for subsequence + optimization problems ✅ Always consider all possible choices ✅ Memoization saves massive computation time ✅ Handling negative values carefully is crucial ✅ Clean recursion = clear logic 🧠💯 🔥 This problem felt like a perfect mix of: 📊 Arrays + 🔁 Recursion + 🧠 DP + 📈 Optimization #LeetCode 🚀 #Java ☕ #DSA 🧠 #DynamicProgramming 📊 #ProblemSolving 💡 #CodingChallenge 💻 #100DaysOfCode 🔥 #DSADiaryByRethanya ✨ #Recursion 🔁 #Memoization 🧩 #LearnInPublic 📢 #TechJourney 🚀
To view or add a comment, sign in
-
Explore related topics
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