Learn Python Coding
39.3K subscribers
648 photos
33 videos
24 files
414 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
Python's deque: Implement Efficient Queues and Stacks

📖 Use a Python deque to efficiently append and pop elements from both ends of a sequence, build queues and stacks, and set maxlen for history buffers.

🏷️ #intermediate #datastructures #python #stdlib
1
"Open Data Structures" is another very useful free resource for anyone studying data structures and algorithms. 📚

The book discusses the implementation and analysis of basic structures: array-based lists, linked lists, hash tables, binary trees, red-black trees, heaps, sorting algorithms, graphs, and data structures for working with integers. 🔍🧮

This is a full-fledged open textbook for studying one of the fundamental topics of computer science and a good reference that's worth keeping on hand. 💻🌟

https://opendatastructures.org/ods-python.pdf 📄

👉 @PythonRe

#DataStructures #Algorithms #Python #ComputerScience #OpenSource #Learning
Please open Telegram to view this post
VIEW IN TELEGRAM
8
Do you know that Python can shift sequences without slicing and creating new lists?

When you need to cyclically shift data, many use slicing:

data = data[-1:] + data[:-1]

But deque.rotate() does this at the level of the data structure and usually works more efficiently for cyclical operations.

q.rotate(1)

A negative value rotates the queue in the other direction.

q.rotate(-2)

This is useful for ring buffers, task schedulers, cyclical queues, and round-robin algorithms.

workers.rotate(-1)

🔥 deque.rotate() allows you to implement cyclical data structures without manual index logic and without creating new lists.

#Python #DataStructures #CodingTips #Programming #Deque #Tech

Join Best TG Channels https://xn--r1a.website/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
2
How to create an object from a dictionary with dot access — without classes and dataclasses?

When you're working with JSON, configurations, or APIs, constant access via dict['key'] clutters the code and worsens readability:

data = {"host": "localhost", "port": 5432}
data["host"]

SimpleNamespace gives the same result, but with dot access:

cfg = SimpleNamespace(**data)
print(cfg.host)

In this case, the object remains dynamic, and you can add fields:

cfg.debug = True

However, the keys must be valid attribute names, and this only works for flat dictionaries (nesting is not converted).

🔥Convenient for prototyping, testing, and simple data.

#Python #DataStructures #SimpleNamespace #CodingTips #DevTools #Programming

Join Best TG Channels https://xn--r1a.website/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
3