TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #60 · 31 мар.

Вторая по частоте future-функция, которую я использовал, это абсолютный импорт from __future__ import absolute_import Что она делает? Изменения, которые вносит эта инъекция описаны в PEP328 Покажу простой пример. Допустим, есть такой пакет: /my_package /__init__.py /main.py /string.py Смотрим код в my_package/main.py # main.py import string Простой пример готов) Вопрос в том, какой модуль импортируется в данном случае? Есть два варианта: 1. модуль в моём пакете my_package.string 2. стандартный модуль string И вот тут вступает в дело приоритет импортов. В Python2 порядок следующий: помимо иных источников, раньше ищется модуль внутри текущего пакета, а потом в стандартных библиотеках. Таким образом мы импортнём my_package.string. Но в Python3 это поведение изменилось. Если мы указываем просто имя пакета, то ищется именно такой модуль, игнорируя имена в текущем пакете. Если мы хотим импортнуть именно подмодуль из нашего пакета то, мы должны теперь явно это указывать. from my_package import string или относительный импорт, но с указанием пути относительно текущего модуля main from . import string Еще одной неоднозначностью меньше 😎 Подробней про импорты здесь: https://docs.python.org/3/tutorial/modules.html #2to3#pep#basic

Резултати

Пронајдени 1 слични објави

Пребарај: #eidpost

当前筛选 #eidpost清除筛选
JS Organization

@jsorganization · Post #401 · 18.06.2024 г., 08:03

Public Wishing With Show Profile Photo Post. Javascript Code🤖 Command Name : /post Code ; Api.sendPhoto({ chat_id: "@JSOrganization",// Replace To Your Channel Username photo:"https://t.me/JSOrganization" , caption: "*👋Hello! @JSOrganization*", parse_mode: "Markdown", reply_markup: {inline_keyboard : [[{text: "CLICK TO WISH ", callback_data: "/post2"}]] } }) Command Name :/post2 Code: // Get the user Telegram ID let userId = user.telegramid; // Array of random wishing captions const randomCaptions = [ "May your wishes come true! 🌟", "Sending you warm wishes on this special day! 🌸", "Wishing you happiness and prosperity!", "May your heart be filled with joy and peace.", "Here's to a wonderful Eid ul Adha celebration!" ]; // Function to get a random element from an array function getRandomElement(array) { return array[Math.floor(Math.random() * array.length)]; } // Define the new property name const newPropertyName = "hasGreeted"; // Check if the user has already greeted if (!User.getProperty(newPropertyName)) { // Increment the total wishes by 1 let totalWishes = Bot.getProperty("total_wishes", 0) + 1; Bot.setProperty("total_wishes", totalWishes, "integer"); // Set a flag to indicate that the user has greeted User.setProperty(newPropertyName, true, "boolean"); // Send the response with an alert Api.answerCallbackQuery({ callback_query_id: request.id, text: `Successfully Wished 🌟\n\nTotal Wishes: ${totalWishes}`, show_alert: true }); // Select a random wishing caption let randomCaption = getRandomElement(randomCaptions); // Prepare the enhanced caption with the updated total wishes count and random wishing caption let caption = `${user.first_name}, wishing you all a blessed Eid ul Adha! 🌸\n\n` + `Thank you for your wish! ${randomCaption}\n\n` + `Total Wishes So Far: ${totalWishes}`; // Edit the message with the updated caption and media Api.editMessageMedia({ chat_id: request.chat_id, message_id: request.message.message_id, media: { type: "photo", media: "t.me/" + user.username, caption: caption }, parse_mode: "markdown", reply_markup: { inline_keyboard: [ [{ text: "✨ Wish Now ✨", callback_data: "/post2"}] ] } }); } else { // User has already greeted, no action needed Api.answerCallbackQuery({ callback_query_id: request.id, text: "You have already greeted!", show_alert: true }); } Replace Your Greetings Random Message As Your Wish 🔴 #Greeting#Wish#EidPost#PublicWish#BotsBusiness#JSOrganization ©@JSOrganization🤖 If Anyone Face Any Error Or Problem. So Message@itsSowrov🙂