python | Unsorted

Telegram-канал python - Python

135201

You will be muted until you read the rules. Read them! @Rules_for_Python A group about the Python programming language. Offtopic things go here: @pythonofftopic Resources to learn python: @pythonres Group for Hy: @hylang Selenium: @SeleniumPython

Subscribe to a channel

Python

functools.cache for sure

Читать полностью…

Python

I think that's the first project you build with Automation with python book.
It also has other cool projects.

I believe he'd benefit alot from that book, especially part II. (Page 183 onwards)

Читать полностью…

Python

Anything you can think of that doesn't require a GUI or external libraries. Since you haven't covered either.

Читать полностью…

Python

Practicing yes, also in the sense of your own projects. Recommended. Contributing to other projects; likely a no.

Читать полностью…

Python

I mean, should I keep learning more Python topics, or is what I’ve learned so far enough to start practicing and working on projects?

Читать полностью…

Python

I’ve learned quite a few Python basics so far: print, variables, data types, if statements, for loops, lists, functions, and dictionaries.

But I still have a lot left to learn, and honestly, I’m starting to feel a bit tired. I wanted to ask someone who’s experienced with Python: do you think what I’ve learned so far is enough to start with, or should I keep learning more before moving on?

Читать полностью…

Python

request.get_json() returns Any in flask stubs, so or {} widens to Any | dict

Читать полностью…

Python

I just wanted to know does it worth to spent years on learning this language and I got my answer

Читать полностью…

Python

tools replace tasks, not thinkers

Читать полностью…

Python

I want to ask about does it worth to learn python in this ai situation? I mean can I even make 1$ or ai wont let me

Читать полностью…

Python

sorry sorry i didn't remember this, actually i thought he is from my own bengali language person that' why btw i will be very careful next time 😅
thanks i will try to help others directly in the chat group from now

Читать полностью…

Python

/channel/rules_for_python/20

Читать полностью…

Python

Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain:

- what you're doing
- what you're expecting
- what you're using
- where you're running the script
- what Python version you're using
- what packages and their versions you're using
- and the most important thing: show the code YOU wrote (read rule 5️⃣ for that)

and more details, that way your chances to get help will increase.

Читать полностью…

Python

It seems you are learning Python in Bengali from an AI. If you need help with Python in Bengali, please feel free to message me privately with more explanation and context.

Читать полностью…

Python

you can type hint it as dict[str, str] in the function signature

Читать полностью…

Python

hi, what's your favourite function from the stdlib?

Читать полностью…

Python

number guessing game tbh

Читать полностью…

Python

What kind of projects, for example?

Читать полностью…

Python

start building projects now

Читать полностью…

Python

before moving on to what?

Читать полностью…

Python

Can you let him figure that out?

Читать полностью…

Python

Why does this line
data: SongPayload = request.get_json() or {}
has this type
Any | dict[Any, Any]?
The issue is
"dict[Any, Any]" is not assignable to "SongPayload" means dict[Any, Any] is the culprit.
Can you get
dict[Any, Any]
out of Any | dict[Any, Any] in data: SongPayload = request.get_json() or {}?

Читать полностью…

Python

fable 5 is wild but it still needs someone to tell it what to build

Читать полностью…

Python

But when I see jev or fable 5.1 they can replace us

Читать полностью…

Python

yaa i think i should to convert this dict[Any,Any] to this payload first in a try-except block and then use this will be fully ok as i can think

Читать полностью…

Python

usually you pass reply_to_message_id=message.message_id in bot.send_message()

Читать полностью…

Python

"dict[Any, Any]" is not assignable to "SongPayload"

Читать полностью…

Python

Asking for DMs is strictly prohibited here 🤷‍♂

Читать полностью…

Python

Why isn't 'reply to message id' working here? 🤨


def send_join_channel_message(chat_id_or_message):
markup = types.InlineKeyboardMarkup()
join_button = types.InlineKeyboardButton(
"Join Our Channel", url=CHANNEL_URL, style="primary"
)
markup.add(join_button)

# ৪টি প্রিমিয়াম ইমোজি সহ সাজানো টেক্সট
text = (
'<tg-emoji emoji-id="5472279086657199080">🤖</tg-emoji> Welcome To Our'
" Bot!\n\n"
'<tg-emoji emoji-id="5274099962655816924">⚠️</tg-emoji> Mandatory Notice:\n'
"To use this bot, you must join our official channel first.\n\n"
'<tg-emoji emoji-id="5875335525136602241">🔗</tg-emoji> Channel Link :'
f" {CHANNEL_URL}\n\n"
'<tg-emoji emoji-id="5298671298757538191">✅</tg-emoji> Once you have'
" joined, please send /start again to begin!"
)

try:
# যদি পুরো message অবজেক্ট পাস করা হয়, তবে ১০০% নিশ্চিতভাবে রিপ্লাই সহ কাজ করবে
if hasattr(chat_id_or_message, "chat") and hasattr(
chat_id_or_message, "message_id"
):
bot.send_message(
chat_id_or_message.chat.id,
text,
reply_markup=markup,
parse_mode="HTML",
reply_to_message_id=chat_id_or_message.message_id,
)
else:
# যদি শুধু chat_id (int) পাস করা হয়, তবে সাধারণ মেসেজ পাঠিয়ে দেবে (ক্র্যাশ করবে না)
bot.send_message(
chat_id_or_message, text, reply_markup=markup, parse_mode="HTML"
)

except Exception as e:
logging.error(f"Error sending join message: {e}")

Читать полностью…

Python

See One Things just adding data:dict[str,str] works fines, but before when i take sugession from ai chat, they say to use like this, what do you say using like below will better or not,

from typing import TypedDict, Optional
# 1. Define the structure of what your JS fetch sends
class SongPayload(TypedDict):
id: str
title: str
image_url: str
artist: str

@general_bp.route("/api/backend/save-song-info", methods=["POST"])
def save_song_info():
# 2. Tell Pylance this json data matches your SongPayload structure
data: SongPayload = request.get_json() or {}

# 3. Now when you type data.get("..."), your IDE will auto-suggest
song_id = data.get("id")
title = data.get("title")
image_url = data.get("image_url")
artist = data.get("artist")

But But But,
Then what i found using TypeDict is one of a good thing so i wish to check like this upper code :->

data: SongPayload = request.get_json() or {} thsi time says new problem
This time upper code says,
Type "Any | dict[Any, Any]" is not assignable to declared type "SongPayload"
  Type "Any | dict[Any, Any]" is not assignable to type "SongPayload"
    "dict[Any, Any]" is not assignable to "SongPayload"PylancereportAssignmentType

What i think using typeDict will a better way but it give this upper problem, anyone knows best solution for this to remove the type problem and as well as the good sugession for all the otehrs parts.
and it say to use cast(), but i listen in real production code i should never use case 😅 now i got trapped out just to solve the type hint problem

Читать полностью…
Subscribe to a channel