🧠 Python Concept: __new__ vs __init__ Object creation vs initialization 😳 ❌ What most people think 👉 __init__ creates the object ✅ Reality class Demo: def __new__(cls): print("Creating instance") return super().__new__(cls) def __init__(self): print("Initializing instance") obj = Demo() 👉 Output: Creating instance Initializing instance 🧒 Simple Explanation 👉 __new__ → creates object 👉 __init__ → initializes object 💡 Why This Matters ✔ Used in immutable types ✔ Important for metaclasses ✔ Helps in advanced object control ✔ Asked in advanced interviews ⚡ Real-World Use ✨ Singleton pattern ✨ Custom object creation ✨ Immutable objects 🐍 Creation first, then initialization 🐍 Understand object lifecycle #Python #AdvancedPython #OOP #SoftwareEngineering #BackendDevelopment #Programming #DeveloperLife
Sahina Rayeesa’s Post
More Relevant Posts
-
🐍 New on wcblog.in: Python Basics — Variables, Data Types, Loops & Functions Explained If you're starting out with Python (or need a solid refresher), I just published a practical, engineer-focused guide covering everything you need to write real Python code from day one: ✅ Variables & data types (int, str, list, dict, set...) ✅ String manipulation & f-strings ✅ Loops — for, while & list comprehensions ✅ Functions, *args, **kwargs ✅ Error handling with try/except ✅ A mini pipeline project to tie it all together Python is the backbone of data engineering, ML, and automation — and it all starts with these fundamentals. 👉 Read the full guide: https://lnkd.in/g92XrVSU #Python #DataEngineering #PythonBasics #LearnPython #Programming #DataEngineer #TechBlog
To view or add a comment, sign in
-
🚨 This behavior of Python might look like a BUG… but it isn’t actually. a = 10 b = 10 print(id(a)) print(id(b)) 👉 Same memory location 😲 “Why do we have two variables pointing to the same memory location?!” Here comes the second one and things get interesting 👇 a = [1, 2, 3] b = a b.append(4) print(a) # [1, 2, 3, 4] 🔥 👉 Hmmm… why did ‘a’ change?! 💡 Explanation: ⭐ id() returns the identity of an object ⭐ Python reuses memory locations for immutable values ⭐ For mutable objects however, there is no copying, just pointers! ⚠️ The misconception: Most people believe ‘=’ copies objects in variables. 👉 Nope! ✅ Solution: b = a.copy() Now the two variables are separate ✅ 🔥 Consequence: It can seriously mess up your program’s logic! Ever got caught by such a ghost bug in Python? 👇 #CodeWithSujith #Python #Programming #Coding #PythonTricks #LearnPython #PythonBeginner #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
-
🧠 Python Concept: lambda functions Write quick functions in one line 😎 ❌ Traditional Way def square(x): return x * x print(square(5)) ❌ Problem 👉 Extra lines 👉 Not always needed ✅ Pythonic Way square = lambda x: x * x print(square(5)) 🧒 Simple Explanation Think of lambda like a mini function ⚡ ➡️ No name needed ➡️ One-line function ➡️ Quick & simple 💡 Why This Matters ✔ Less code ✔ Useful for short operations ✔ Works great with map(), filter() ✔ Cleaner for small tasks ⚡ Bonus Example nums = [1, 2, 3, 4] even = list(filter(lambda x: x % 2 == 0, nums)) print(even) 🐍 Small functions, big impact 🐍 Keep it simple & Pythonic #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
I didn’t really understand NumPy until I asked a simple question: Why was it even created in the first place? Python, by design, is flexible and easy to use… but that flexibility comes at a cost. When developers started using Python for scientific computing and data-heavy tasks, they ran into real problems: * Working with large numerical data was slow * Memory usage was inefficient * Simple operations required too many loops and too much code And that’s exactly where NumPy came in. It wasn’t created to “add features” to Python — it was created to fix a bottleneck. NumPy introduced a new way of handling data: A structured, typed array that allows computations to happen at a much lower level (closer to C speed), while still writing code in Python. So instead of telling Python how to loop through every element… you just tell NumPy what operation you want — and it handles the rest efficiently. That shift is the real innovation. NumPy is not just about arrays. It’s about changing the way computation is done in Python — from step-by-step instructions to vectorized thinking. And that’s why it became the foundation of everything that came after it. #Python #NumPy #DataScience #MachineLearning #SoftwareEngineering
To view or add a comment, sign in
-
-
📅 Day 75 – Higher Order Functions using filter() 🚀🐍 Today I practiced filter() function in Python to select required data from lists 💡 🔹 Filtered even numbers from a list ⚖️🔢 🔹 Filtered odd numbers from a list 🔀🔢 🔹 Selected numbers greater than 10 ⬆️🔢 🔹 Applied condition-based filtering on numeric data ✔️ 🔹 Filtered words that start with vowels (a, e, i, o, u) 🔤 🔹 Learned string-based filtering using conditions 📏 💡 Understood how filter() helps in extracting only required elements from a dataset ⚡ 💡 Improved logic building with lambda functions + conditions 🧠 🔥 Feeling more confident in functional programming and data filtering in Python! #Day75 #Python #FilterFunction #HigherOrderFunctions #CodingJourney #LearnPython #WomenInTech #FutureEngineer 🚀✨
To view or add a comment, sign in
-
-
🚀 Day 5 of My 30-Day Python Journey Today’s focus was on working with one of the most commonly used data types in programming strings. 🔹 What I covered today: • Understanding string indexing and slicing • Extracting and manipulating text efficiently • Using built-in string methods (upper(), lower(), replace(), strip(), etc.) • Writing cleaner and more readable code using f-strings 💡 Key Takeaway: Handling text data effectively is a fundamental skill. From user input to data processing, strong string manipulation makes programs more powerful and practical. 🧪 Practice Focus: Worked on mini tasks like reversing a string, checking palindromes, counting characters, and cleaning user input (email formatting). 📌 Next Step: Moving into lists and data collections to manage multiple values efficiently. Consistency and clarity building step by step. 💻 #Python #CodingJourney #LearnToCode #Developers #Programming #TechGrowth #100DaysOfCode
To view or add a comment, sign in
-
-
🧠 Python Concept: Mutable vs Immutable Why your data changes… or doesn’t 😳 ❌ Confusing Behavior x = [1, 2, 3] y = x y.append(4) print(x) 👉 Output: [1, 2, 3, 4] 😵💫 🧒 Why? 👉 Lists are mutable (can change) 👉 Both x and y point to same object ✅ Immutable Example x = (1, 2, 3) y = x y = y + (4,) print(x) 👉 Output: (1, 2, 3) ✅ 🧒 Simple Explanation 👉 Mutable = can change 🧱 👉 Immutable = cannot change 🔒 💡 Why This Matters ✔ Avoid unexpected bugs ✔ Important for memory understanding ✔ Used in real-world debugging ✔ Frequently asked in interviews ⚡ Bonus Tip x = [1, 2, 3] y = x.copy() 👉 Now changes in y won’t affect x 🐍 Know your data types 🐍 Small concept, big impact #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
New Skill Unlocked: NumPy Basics! ✅ I've just wrapped up the fundamental concepts of the NumPy library. It's incredible to see how this tool serves as the foundation for almost every data-heavy python project Onward to Pandas! 🐼 #DataAnalytics #NumPy #Python #Programming Creating & Reshaping Data In data science, we often need to change the shape of our data (like turning a long list of numbers into a grid or matrix). NumPy makes this a one-liner. import numpy as np Create a 1D array of 12 numbers (0 to 11) data = np.arange(12) Reshape it into a 3x4 matrix (3 rows, 4 columns) matrix = data.reshape(3, 4) print(matrix) # Output: # [[ 0 1 2 3] # [ 4 5 6 7] # [ 8 9 10 11]] #DataAnalytics #NumPy #Python #Programming #machinelearning #dataScience #pandas
To view or add a comment, sign in
-
🚀 Python Mini Project: Matrix Operations Tool (NumPy) I built a Matrix Operations Tool using Python and NumPy that performs essential matrix computations efficiently. This project focuses on simplifying mathematical operations on matrices while ensuring accuracy and performance using optimized NumPy functions. It is designed to handle different matrix sizes and provide reliable results through proper input validation. 🔧 Key Features :- • Matrix Addition, Subtraction, and Multiplication • Transpose of a Matrix • Determinant Calculation • Handles multiple matrix sizes • Input validation to prevent runtime errors 💻 Tech Used :- • Python • NumPy This project helped me strengthen my understanding of linear algebra concepts and improved my ability to work with numerical data efficiently. It also gave me practical experience in writing optimized and clean code using NumPy instead of manual implementations. 🔗 GitHub Repository :- https://lnkd.in/g2mT5Zj2 I am continuously working on improving my skills and building projects that solve real-world problems. Feedback and suggestions are always welcome. #Python #NumPy #Projects #SoftwareDevelopment #BackendDeveloper #CodingJourney #OpenToWork
To view or add a comment, sign in
-
🔁 Python Revision – Sets Continuing my Python fundamentals revision 🐍 In this session, I focused on: ✔️ Sets (creation and properties) ✔️ Unique elements and unordered nature ✔️ Set methods (add, remove, discard, etc.) ✔️ Set operations (union, intersection, difference) Practiced using sets to handle unique data and perform efficient operations like finding common or different elements between datasets. Documented my practice in a Jupyter Notebook and shared it as a PDF to track my progress. Understanding sets is helping me work better with data and avoid duplicates 📊 Next: dictionaries and real-world data handling 🚀 #Python #Revision #Sets #Programming #DataAnalytics #LearningJourney #Coding
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