<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MAHDI</title>
    <description>The latest articles on DEV Community by MAHDI (@mahdi2244).</description>
    <link>https://dev.to/mahdi2244</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4055215%2F911b6ee0-8a56-4bf5-b857-8491d6e8a7d6.png</url>
      <title>DEV Community: MAHDI</title>
      <link>https://dev.to/mahdi2244</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahdi2244"/>
    <language>en</language>
    <item>
      <title>Python</title>
      <dc:creator>MAHDI</dc:creator>
      <pubDate>Fri, 07 Aug 2026 20:15:43 +0000</pubDate>
      <link>https://dev.to/mahdi2244/python-1g0p</link>
      <guid>https://dev.to/mahdi2244/python-1g0p</guid>
      <description>&lt;p&gt;When I wrote my first Python script, I thought programming was just about typing instructions and getting output. I was wrong. 😅&lt;/p&gt;

&lt;p&gt;After dozens of scripts (and countless errors), I realized Python is not just a language – it's a way of thinking. Here are 5 concepts that changed everything for me.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variables Are Names, Not Boxes
In many languages, variables are like boxes where you store values. In Python, they're more like labels pointing to objects.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;python&lt;br&gt;
a = [1, 2, 3]&lt;br&gt;
b = a&lt;br&gt;
b.append(4)&lt;/p&gt;

&lt;p&gt;print(a)  # [1, 2, 3, 4]  ← Surprise! 'a' changed too!&lt;br&gt;
Why? Because a and b point to the same list object. You didn't copy the list – you copied the reference.&lt;/p&gt;

&lt;p&gt;Fix:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
b = a.copy()  # Now they're independent&lt;br&gt;
Understanding this early saves hours of debugging "mysterious" bugs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Power of f-Strings
I used to concatenate strings like a caveman:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;python&lt;br&gt;
name = "Mahdi"&lt;br&gt;
age = 25&lt;br&gt;
print("My name is " + name + " and I am " + str(age) + " years old.")&lt;/p&gt;

&lt;h1&gt;
  
  
  So much + and str()... ugh.
&lt;/h1&gt;

&lt;p&gt;Then I discovered f-strings:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
print(f"My name is {name} and I am {age} years old.")&lt;/p&gt;

&lt;h1&gt;
  
  
  Clean. Readable. Beautiful.
&lt;/h1&gt;

&lt;p&gt;And you can even put expressions inside:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
print(f"Next year I'll be {age + 1}.")&lt;br&gt;
print(f"My name in uppercase: {name.upper()}")&lt;br&gt;
Once you go f-string, you never go back.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;List Comprehensions Are Not Scary
I used to write 4-line loops for simple list operations:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;python&lt;br&gt;
squares = []&lt;br&gt;
for i in range(10):&lt;br&gt;
    if i % 2 == 0:&lt;br&gt;
        squares.append(i ** 2)&lt;br&gt;
Then I learned this one-liner:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
squares = [i ** 2 for i in range(10) if i % 2 == 0]&lt;/p&gt;

&lt;h1&gt;
  
  
  Result: [0, 4, 16, 36, 64]
&lt;/h1&gt;

&lt;p&gt;The structure: [expression for item in iterable if condition]&lt;/p&gt;

&lt;p&gt;Another real-world example:&lt;/p&gt;

&lt;p&gt;python&lt;/p&gt;

&lt;h1&gt;
  
  
  Get all active usernames in uppercase
&lt;/h1&gt;

&lt;p&gt;usernames = [user.name.upper() for user in users if user.is_active]&lt;br&gt;
Readable. Pythonic. Fast.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Functions Are First-Class Citizens
In Python, you can pass functions as arguments, store them in lists, return them from other functions...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;python&lt;br&gt;
def greet(name):&lt;br&gt;
    return f"Hello, {name}!"&lt;/p&gt;

&lt;p&gt;def shout(func):&lt;br&gt;
    return func().upper()&lt;/p&gt;

&lt;h1&gt;
  
  
  Passing a function
&lt;/h1&gt;

&lt;p&gt;print(shout(lambda: greet("Mahdi")))  # HELLO, MAHDI!&lt;br&gt;
This opens the door to decorators, callbacks, and cleaner code architecture.&lt;/p&gt;

&lt;p&gt;Real use case – sorting with a custom key:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
students = [{"name": "Ali", "grade": 85}, {"name": "Sara", "grade": 92}]&lt;br&gt;
sorted_students = sorted(students, key=lambda s: s["grade"], reverse=True)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Virtual Environments Will Save You
I ignored virtual environments for months. Biggest mistake.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without them:&lt;/p&gt;

&lt;p&gt;Project A needs requests==2.25&lt;/p&gt;

&lt;p&gt;Project B needs requests==2.28&lt;/p&gt;

&lt;p&gt;Chaos. Dependency hell. Tears.&lt;/p&gt;

&lt;p&gt;With virtual environments:&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;

&lt;h1&gt;
  
  
  Create one per project
&lt;/h1&gt;

&lt;p&gt;python -m venv venv&lt;/p&gt;

&lt;h1&gt;
  
  
  Activate it
&lt;/h1&gt;

&lt;p&gt;source venv/bin/activate  # Linux/Mac&lt;br&gt;
venv\Scripts\activate     # Windows&lt;/p&gt;

&lt;h1&gt;
  
  
  Install whatever you want – it stays isolated
&lt;/h1&gt;

&lt;p&gt;pip install requests pandas numpy&lt;br&gt;
Clean. Isolated. Professional.&lt;/p&gt;

&lt;p&gt;Pro tip: Always add venv/ to your .gitignore file.&lt;/p&gt;

&lt;p&gt;🎁 Bonus: The if &lt;strong&gt;name&lt;/strong&gt; == "&lt;strong&gt;main&lt;/strong&gt;" Mystery Solved&lt;br&gt;
I saw this everywhere but didn't understand it:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
def main():&lt;br&gt;
    print("Running the script...")&lt;/p&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == "&lt;strong&gt;main&lt;/strong&gt;":&lt;br&gt;
    main()&lt;br&gt;
What it means:&lt;/p&gt;

&lt;p&gt;When you run the script directly: python script.py → main() executes&lt;/p&gt;

&lt;p&gt;When you import it: import script → main() does NOT execute&lt;/p&gt;

&lt;p&gt;It separates code that should only run when the script is executed directly from code that should always be available on import.&lt;/p&gt;

&lt;p&gt;📝 Summary Table&lt;br&gt;
Concept Why It Matters&lt;br&gt;
Variables as references Avoids unexpected mutations&lt;br&gt;
f-Strings   Cleaner, faster string formatting&lt;br&gt;
List Comprehensions Less code, more readability&lt;br&gt;
First-Class Functions   Enables decorators and flexible APIs&lt;br&gt;
Virtual Environments    Dependency isolation per project&lt;br&gt;
🚀 What's Next?&lt;br&gt;
These 5 concepts transformed how I write Python. I'm now building automation scripts with n8n and Docker, and these fundamentals make every step smoother.&lt;/p&gt;

&lt;p&gt;What Python concept took you way too long to understand? Drop it in the comments – let's help the next beginner skip our mistakes! 🐍&lt;/p&gt;

&lt;h1&gt;
  
  
  python #beginners #programming #tutorial #softwaredevelopment #learning
&lt;/h1&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>اولین پست</title>
      <dc:creator>MAHDI</dc:creator>
      <pubDate>Tue, 04 Aug 2026 14:08:10 +0000</pubDate>
      <link>https://dev.to/mahdi2244/wlyn-pst-193e</link>
      <guid>https://dev.to/mahdi2244/wlyn-pst-193e</guid>
      <description>&lt;h1&gt;
  
  
  👋 سلام، من مهدی هستم!
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;دانش‌آموز رشته کامپیوتر | علاقه‌مند به DevSecOps، امنیت سایبری، و استارتاپ&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;این اولین پست من در Dev.to هست و خوشحالم که این مسیر رو با شما شروع می‌کنم.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 من کی هستم؟
&lt;/h2&gt;

&lt;p&gt;من مهدی هستم، یه دانش‌آموز رشته کامپیوتر که به دنیای برنامه‌نویسی، امنیت، و زیرساخت علاقه دارم.&lt;/p&gt;

&lt;p&gt;توی این چند ماه، با ابزارها و مفاهیم مختلفی آشنا شدم:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🐍 پایتون و #C&lt;/li&gt;
&lt;li&gt;🐳 Docker و کانتینرها&lt;/li&gt;
&lt;li&gt;🤖 اتوماسیون با n8n&lt;/li&gt;
&lt;li&gt;🔐 مبانی امنیت و DevSecOps&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 هدف من از اینجا؟
&lt;/h2&gt;

&lt;p&gt;این پلتفرم رو انتخاب کردم تا:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;تجربیات یادگیری‌ام رو به اشتراک بذارم&lt;/li&gt;
&lt;li&gt;با آدم‌های هم‌فکر ارتباط برقرار کنم&lt;/li&gt;
&lt;li&gt;و مسیرم رو به سمت ساختن استارتاپ &lt;strong&gt;Majenta&lt;/strong&gt; ادامه بدم&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🌟 امیدوارم که...
&lt;/h2&gt;

&lt;p&gt;بتونم بهترین خاطرات رو با شما رقم بزنم و از دانش و تجربه‌تون یاد بگیرم.&lt;/p&gt;




&lt;p&gt;💬 &lt;strong&gt;شما چه مسیری رو انتخاب کردید؟&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
خوشحال می‌شم توی کامنت‌ها، داستان خودتون رو به اشتراک بذارید.&lt;/p&gt;




</description>
      <category>cybersecurity</category>
      <category>developer</category>
      <category>learning</category>
      <category>startup</category>
    </item>
  </channel>
</rss>
