Learn Python Coding
40.8K subscribers
722 photos
37 videos
24 files
538 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
Voluptuous - Data Validation in Python

Voluptuous is a Python library for data validation using schemas. It allows you to define acceptable values for fields and validate data received from users, APIs, or other sources.

To get started, import the library:

import voluptuous as v


https://t.me/pythonRe
❤2
This channels is for Programmers, Coders, Software Engineers.

0️⃣ Python
1️⃣ Data Science
2️⃣ Machine Learning
3️⃣ Data Visualization
4️⃣ Artificial Intelligence
5️⃣ Data Analysis
6️⃣ Statistics
7️⃣ Deep Learning
8️⃣ programming Languages

✅ https://t.me/addlist/8_rRW2scgfRhOTc0

✅ https://t.me/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3
If you trade cryptocurrencies and are feeling confused about the current market, I strongly recommend you join the group I’ve mentioned

The group shares the following content every day:

✅ One trading signal a day (with a success rate of up to 85%)
✅ Real-time updates on cryptocurrency market trends
✅ Personalised, one-to-one technical trading advice

Whether you’re a beginner or an experienced trader, you’re welcome to join the group to exchange ideas and gain useful insights

Join now;https://walink.ai/agdK2Qq
🌟 Detecting Hallucinations in LLM Responses through Perplexity Calculation 🤖

Hallucinations in language models lead to the generation of false, yet convincingly sounding, facts. 📝
Calculating the perplexity of the generated text allows us to assess the model's confidence in its responses. 📊
We will write a Python script to calculate perplexity and filter out questionable generations. 🐍

Let's install the
transformers

and
torch

libraries to work with language models and calculate perplexity.
pip install transformers torch

The libraries for calculating perplexity have been successfully installed. ✅

Let's create a Python script called
perplexity_check.py

that calculates the perplexity level for a given text.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

inputs = tokenizer("Example text for perplexity check.", return_tensors="pt")
with torch.no_grad():
    outputs = model(**inputs, labels=inputs["input_ids"])
print("Loss value:", outputs.loss.item())

The perplexity calculation script has been successfully created and is ready to run. 🚀
# Verify the script's functionality
python3 -c "import torch; print('PyTorch Ready')"

Expected output:
PyTorch Ready

# cleanup (remove the test script)
rm -f perplexity_check.py

An abnormally high perplexity often indicates that the model has started "hallucinating" and generating illogical text. 🚫

Integrate this threshold into safety filters (Guardrails) to automatically block incorrect responses. 🛡️

https://t.me/pythonRe

#Python #AI #LLM #MachineLearning #Coding #Tech

🌟 Join Best TG Channels
https://t.me/addlist/0f6vfFbEMdAwODBk

⭐️ Join Our WhatsApp Channel
https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4
inspect.getattr_static() — Retrieving attributes without executing external code!

The standard getattr() function doesn't always simply read an attribute. It can invoke a @property, a descriptor, or a custom __getattr__, potentially triggering arbitrary object logic.
class User:    @property    def token(self):        print("Loading token...")        return "secret"user = User()print(getattr(user, "token"))# Loading token...# secret


This behavior can be undesirable for object analysis tools.

The standard library provides inspect.getattr_static(), which retrieves an attribute without the usual dynamic access mechanism.
from inspect import getattr_staticattr = getattr_static(user, "token")print(type(attr))# <class 'property'>


Instead of executing the property, the function returns the property object itself. This allows you to inspect the class structure without executing the code associated with reading the attribute.

This is useful when working with objects that dynamically create attributes using getattr.
class Config:    def __getattr__(self, name):        print(f"Loading {name}")        return 42config = Config()print(getattr(config, "timeout"))# Loading timeout# 42


getattr_static() does not call __getattr__. Therefore, you can check for a missing attribute without any side effects.
print(getattr_static(config, "timeout", None))# None


Static retrieval does not guarantee the same value as the standard getattr(). It may return a descriptor instead of the computed value, and it may not discover some dynamically accessible attributes at all.

🔥 inspect.getattr_static() allows you to inspect object attributes without executing properties or custom access methods, which is useful when developing debuggers, serializers, and code analysis tools.

https://t.me/pythonRe ✈️
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3
Forwarded from Machine Learning
🔥 Free IT & Dev Study Kits + Double 11 Giveaway 🎁

Prepping for cloud, dev, or AI roles? These free kits cover the gaps most people skip:
📘 Cert E-Book (Cisco & AWS) → https://tinyurl.com/ynutkhec
🪜 Free Online Course → https://tinyurl.com/4kvuk4m6
☁️ Free AI Materials → https://tinyurl.com/2z46z8f4

🎉 Black Friday Lucky Draw — win iPhone Duo, $50 Amazon Gift Card, Blinkstory Coins, PMP/Cisco training & more!
👉 Join Lucky Draw Now: https://www.spotoexam.com/snsblackfriday2026/?id=snscxy
🌐 Community draw: https://chat.whatsapp.com/KkbnOUuS55aJdZMtTGrVYL
📲 Admin Noya: https://wa.me/8619559123054

📌 Save or forward to your study group — good resources are worth sharing! 💪
❤3
🛑 Cloudflare killing your bots?

Peak clears Turnstile and the 5-second
"Just a moment" wall in one API call.

Pay only when it solves
$0.35/1k at volume,
cheaper than CapSolver
Proxyless option, bring no proxies
Drop-in API, token back in seconds

🎟 15% off your first top-up: PEAK15
Free trial, no card.

👉 peak.fo / @peakfo
❤1
🔥⚡️ —Follow this channel on WhatsApp for more cryptocurrency news and trading strategies

✅ One trading signal shared daily (with a win rate as high as 85%)

✅ Real-time cryptocurrency market updates

✅ One-on-one technical trading guidance

Whether you’re a beginner or an experienced trader, you’re welcome to join to exchange ideas and gain valuable insights

Join:https://t.me/+lB_9L7niB_lhZjE0
❤1
Learn Python Coding pinned «🔥⚡️ —Follow this channel on WhatsApp for more cryptocurrency news and trading strategies ✅ One trading signal shared daily (with a win rate as high as 85%) ✅ Real-time cryptocurrency market updates ✅ One-on-one technical trading guidance Whether you’re…»