🚀 The `__name__` Variable (Python) Every Python module has a built-in variable named `__name__`. When a module is run directly, `__name__` is set to `"__main__"`. When a module is imported, `__name__` is set to the module's name. This allows you to write code that executes only when the module is run as a script, not when it's imported. Learn more on our website: https://techielearns.com #Python #PythonDev #DataScience #WebDev #professional #career #development
Understanding Python's __name__ Variable
More Relevant Posts
-
🚀 The `__all__` Variable in Modules and Packages (Python) The `__all__` variable is a list of strings defining the public names of a module or package. When `from module import *` is used, only the names listed in `__all__` are imported. If `__all__` is not defined, all names that do not begin with an underscore are imported. It provides explicit control over the module's public API. Learn more on our website: https://techielearns.com #Python #PythonDev #DataScience #WebDev #professional #career #development
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
-
📌 Python Sets – Add & Update Methods I practiced how to add new elements to a set using add() and update() methods. ✅ add() → Adds one single element to a set ✅ update() → Adds multiple elements from another set (or iterable) 🧩 Example: # Add one item myset.add("Grapes") # Add multiple items set1.update(set2) #Python #LearningPython #DataAnalytics #PythonSets #CodingJourney #Upskilling
To view or add a comment, sign in
-
-
🐍 Day 32 — Writing Clean Python Code Day 32 of #python365ai ✨ Clean code is easier to read, understand, and maintain. Good practices: - Meaningful variable names - Consistent formatting - Simple logic Example: total_score = marks + bonus 📌 Why this matters: Clean code is a professional habit — especially in teamwork and research. 📘 Practice task: Refactor a small script to improve readability. #python365ai #CleanCode #BestPractices #Python
To view or add a comment, sign in
-
-
Most Python bugs don’t happen because the logic is wrong. They happen because we keep solving common, boring problems in bad ways. Some Python libraries that helped me fix this: cattrs – helps handle structured data instead of messy dictionaries hypothesis – finds bugs by testing cases you didn’t think about pyrsistent – makes shared data safer and more predictable msgspec – shows how slow normal JSON handling can be watchfiles – reliable file watching without random issues datasketch – handles large-data problems in a simple way These libraries don’t make your code fancy. They make it more stable and harder to break. #Python #CleanCode #SoftwareEngineering #ProgrammingTips #DeveloperCommunity
To view or add a comment, sign in
-
-
🚀 Comments (Python) Comments are used to add explanatory notes to your code. They are ignored by the Python interpreter. Single-line comments start with a `#` symbol. Multi-line comments are enclosed in triple quotes (`'''` or `"""`). Comments are crucial for improving code readability and maintainability. They help other developers (and yourself) understand the purpose of the code. #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
🚀 Function Arguments and Parameters (Python) Parameters are placeholders for values that a function expects to receive when called. Arguments are the actual values passed to the function during a call. Python supports positional arguments, where the order matters, and keyword arguments, where the argument is explicitly associated with a parameter name using `name=value`. Default parameter values can be specified in the function definition, allowing the function to be called without providing a value for that parameter. #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
Am I too late? I just discovered match-case in Python! If you have used "switch-case" in other languages, "match-case" is Python’s way of doing something similar, but with more flexibility. It helps handle multiple conditions in a clean, readable way. Where it really comes in handy: 1. Routing logic in applications (choosing actions based on user input). 2. Handling different types of messages or events. 3. Simplifying long if / elif / else chains. 4. Working with structured data like tuples, lists, or dictionaries. Honestly, it makes your code much easier to read and maintain when there are multiple possibilities to consider. If you are just finding out about it like I did, I would definitely recommend checking it out and getting familiar with how it works, you might be surprised. If you have used it before, I’d love to hear your take on it. #Python #BackendDevelopment
To view or add a comment, sign in
-
Let's look at Python (in)consistency: >>> s='a' >>> s.split()==s.split(' ') True >>> s='' >>> s.split()==s.split(' ') False How come? The point here -- let me quote the docs -- "If sep is not specified or is None, a different splitting algorithm is applied". If separator is not specified, empty strings at the beginning and the end of the result are discarded, so while ''.split(' ') is [''], ''.split() is []. #Python #gotcha
To view or add a comment, sign in
-
🧠 “Interesting Python Nugget” (Lists) Python List Trick You’ll Actually Use Did you know you can remove duplicates from a list in ONE line? nums = [1, 2, 2, 3, 4, 4] unique_nums = list(set(nums)) ✔ Simple ✔ Fast ✔ Super handy for real projects Python has tons of these tiny gems that save time and make code cleaner. 📬 We explain one Python concept every day — short, clear, and practical. Want more? Subscribe and learn Python daily ✨ link in the comments Please sign up and follow #PythonChallenge #PythonLearning #CodeChallenge #PythonDaily #PyDaily
To view or add a comment, sign in
-
More from this author
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