Writing comments in python. Have you ever inspected a python code? And at some point you see a line that starts with a Hashtag #.? That's a comment This is the human consumption part that the interpreter will not execute. Simply put the computer will not execute that line of code. Can you think of having a conversation with a friend about fixing a broken tube for an electric bike? After identifying the puncture in the cause of fixing the tube, you instructed him to be careful when ever he is riding on a rough path. Off course that was nice but not part of the fixing process. though that instructions was taken in, it was not part of the executed instructions on fixing the tube Or can you give a better example than this in the comments section? Comments in Python is a line written in the code which explains what the code does. 🎄It help human read the code and understand what the code does. 🎄 It can describe. explain or remind one about some actions in the code 🎄 Comments allow you and team members understand code and action. 🎄 Comments enhances functionality and structure in which the code is based 🎄 Comments could prevent execution of some part of the code. 🎄It is a good practice to allow comments to be short and precise. Do you have some other things to add? #python #comment #execution #lineofcode
Python Commenting: Explanation and Purpose
More Relevant Posts
-
Why range(1,000,000) is cheap, but list(range(1,000,000)) is costly in Python? TL;DR: Iteration Protocol in Python needs to know only next item and not full list. The "Next Page" Rule Iteration in Python isn't about having a collection of items; it’s about knowing how to get the next item. Two special methods make this possible: 1. __iter__() → tells Python “I can be looped over” 2. __next__() → returns the next value, one at a time When there’s nothing left, StopIteration tells Python to stop the loop. Why this matters? When we use a list, we pay for all the memory upfront. When we use the Iteration Protocol, we only pay for one item at a time. This is called Lazy Evaluation. Takeaway - If the object represents a collection or a stream of data, implement __iter__ and __next__. It makes the code more memory-efficient and much more "Pythonic." I’m deep-diving into the Python protocols this week and will share my learnings. Do follow along and tell your experiences in comments. #Python #PythonInternals #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
https://lnkd.in/e73QC5-9 FST fst Version 0.2.5 Overview This module exists in order to facilitate quick and easy high level editing of Python source in the form of an AST tree while preserving formatting. It is meant to allow you to change Python code functionality while not having to deal with the details of: Operator precedence and parentheses Indentation and line continuations Commas, semicolons, and tuple edge cases Comments and docstrings Various Python version-specific syntax quirks Lots more...
To view or add a comment, sign in
-
Python devs, this one is a big deal 👀 If you’ve ever written a CPU-heavy Python script, watched only one core max out, and whispered “thanks, GIL” under your breath, this is for you. Python 3.12 quietly introduced something foundational for performance: Subinterpreters with per-interpreter GILs (PEP 684). What does that mean in practice? True parallelism for CPU-bound Python code Multiple interpreters inside a single process No heavyweight multiprocessing, no pickling overhead A real path toward multi-core Python without burning memory In my latest post, I walk through: Why the GIL has been the wall for years How subinterpreters change Python’s execution model An experimental example using _xxsubinterpreters Why this matters more right now than “GIL removal” headlines This is the groundwork for Python’s high-performance future — and it’s already here. 👉 Read the full breakdown here: https://lnkd.in/gcfsn2U3 Would love to hear how you’re thinking about concurrency in Python 👇 #Python #Python312 #PerformanceEngineering #Concurrency #BackendEngineering #SoftwareArchitecture #GIL #pythonInPlainEnglish
To view or add a comment, sign in
-
How does len() function knows how to handle a List, a String, and a Dictionary all the same way in Python? TL;DR: Python Protocols A Protocol is just the set of rules (special methods) an object follows. "Duck Typing" Contract In Python does not care about what the object is, it cares only about what it does. These are represented as dunders (__method__) in Python. 3 Protocols we use everyday in Python: -> Sized (__len__): Tells Python that object has a size. (Powers len()) -> Container (__contains__): Tells Python how to check if something is "inside" the object. (Powers the in keyword) -> Iterable (__iter__): Tells Python that object can be looped over. (Powers for x in obj) Why is this useful? As a developer, we want our code to be intuitive. By following these protocols, we make our custom objects compatible with all of Python’s built-in tools. Protocols are the API of the Python language itself. Using them make custom objects start feeling like native Python parts. I’m deep-diving into the Python protocols this week and will share my learnings. Do follow along and tell your experiences in comments. #Python #PythonInternals #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
What is Integer Interning in Python? Why is 256 is 256, but 257 is different in Python? Integer Interning is a memory optimisation technique used in Python. In most programs, small numbers like 0, 1, 10, -1 are used most of the times (loop counters, indexes, flags, etc.). Creating a brand new object every time would waste a lot of memory. So what Python does is this - When Python starts, it pre-creates and stores integers from -5 to 256. a = 10 → Python reuses the existing 10 b = 10 → points to the same object in memory So a is b is True. 257 is not in the pre-created pool. a = 257 → new object b = 257 → another new object Same value, different memory locations → is returns False. Note: The exact integer pool range and behaviour can differ based on Python version, implementation, and execution context. Takeaway - Using is for comparisons should be done cautiously. It checks identity, not value, and can lead to unusual bugs. I am trying to learn Python Internals in detail and will share my learnings. Do follow along and tell your experiences in comments. #Python #PythonInternals #SoftwareEngineering #BackendDevelopment
To view or add a comment, sign in
-
-
🧠 Python Feature That Feels Like a Cheat Code: enumerate() Most beginners write this 👇 i = 0 for item in items: print(i, item) i += 1 But Python says… why work so hard? 😌 ✅ Pythonic Way for i, item in enumerate(items): print(i, item) 🧒 Simple Explanation Imagine numbering students in a line 🧑🎓 enumerate() gives you: ✨ the number ✨ the student at the same time 🎯 💡 Why It’s Important ✔ Cleaner code ✔ Fewer bugs ✔ More readable ✔ Very common in interviews ⚡ Bonus Tip Start counting from 1: for i, item in enumerate(items, start=1): print(i, item) ✔️ Python rewards clean thinking. ✔️ If you’re manually counting in a loop… Python already has a better way 🐍✨ #Python #PythonTips #CleanCode #LearnPython #DeveloperLife #Coding
To view or add a comment, sign in
-
-
🐍 Day 4: Python Full-Stack Journey - Multiple Variable Initialization Today I explored one of Python's elegant features that makes code cleaner and more readable: initializing multiple variables in a single line! What I Learned: Python allows us to assign values to multiple variables simultaneously, which can make our code more concise and expressive. Examples from my practice: python # Basic multiple assignment x, y, z = 10, 20, 30 # Swapping values (no temp variable needed!) a, b = 5, 10 a, b = b, a # Now a=10, b=5 # Unpacking from lists/tuples name, age, city = ["Alice", 25, "New York"] # Same value to multiple variables x = y = z = 0 # Unpacking with * operator first, *middle, last = [1, 2, 3, 4, 5] # first=1, middle=[2,3,4], last=5 Why This Matters: This feature demonstrates Python's philosophy of writing clean, readable code. It's especially useful when working with functions that return multiple values or when processing data structures in full-stack applications. Key Takeaway: Python's multiple assignment isn't just syntactic sugar—it's a powerful tool that can make code more maintainable and Pythonic! What's your favorite Python feature that makes coding more elegant? Drop it in the comments! 👇 #Python #100DaysOfCode #FullStackDevelopment #LearnInPublic #PythonProgramming #CodingJourney #TechLearning
To view or add a comment, sign in
-
-
I didn't understand why functions mattered when I first learned Python. My instructor kept saying: "Don't repeat yourself. Use functions" 🤔 I thought: Why? Copy paste works fine. Then I wrote some repeated logic in my code, the same check appeared more than once. When I found a mistake, I had to fix it in multiple places. That's when it clicked.💡 Functions aren’t just a Python feature. They’re a way to write smarter, maintainable code. The rule I follow now: If I’m writing the same logic twice → make it a function. Why functions matter: • One source of truth 📌 • Fewer bugs 🐞 • Easier updates 🔧 • Code that’s easier to read 👀 I wish I had understood this earlier instead of just memorizing syntax. 📚 Now, when I write code, I ask: “Will I need this logic again?” If yes → function. Functions didn’t just make my code shorter. They made it maintainable. If you’re learning Python, don’t skip functions thinking they’re “advanced.” They’ll save you hours of debugging later.⏱️ What Python concept took you time to really understand? #Python #Programming #CleanCode #LearnInPublic #SoftwareDevelopment
To view or add a comment, sign in
-
-
Tuples in Python: Immutable (cannot be changed after creation), ordered collection that allows duplicate elements. Syntax:() Two methods: Index(),count() Python 3.14.0 (tags/v3.14.0:ebf955d, Oct 7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)] on win32 Enter "help" below or click "Help" above for more information. >>> #tuples() >>> a=(4,5.7,"python",4+9j,True,False) >>> print(a) (4, 5.7, 'python', (4+9j), True, False) >>> type(a) <class 'tuple'> >>> len(a) 6 >>> a.count("python") 1 >>> a.index(True) 4 Pooja Chinthakayala Mam,Saketh Kallepu Sir,Uppugundla Sairam Sir
To view or add a comment, sign in
More from this author
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