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

Depending on how much JS you need to inject, you could consider using .format() on a js as a string and replace the values that way 🤷‍♂

So you skip all the python > html > js dance
https://docs.python.org/3/builtins/stdtypes.html#str.format

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

Python

yaa thats looks logical now, i will do serachElementBYID in my js code from a hidden <span> and from there the js will take the value 😅

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

Python

Hello, I was using Flask to build HTML with Jinja and send it to the user's browser like this: 🐍

return render_template("index.html", user=user_data, money=users_db.money_value,)

for this case, user and money values are inserted into the Flask template on the fly coming from Python3.

However, when I try to send the
/static/js/filename.js
file, it is served automatically. As a result, I have to hardcode each variable in the .js file, since Flask automatically sends the .js file to the user without dynamic context. 😢

var UUID_RE =-Za-z0-9_-]+)/;

var SHORT_RE = ([A-Za-z0-9_-]+)/i;
var HOOK_RE = -9a-f]{4}-[0-9a-f]{12})/i;

var DEFAULT_PROXY = "/api/endpoint/somethign?url=";
var HOOK_API = "/video/web/somethign";


The content above is from my different .js files as an example. To clarify, I want my JS files to also be dynamic, similar to how I pass user and money values in the HTML. I want to pass values to the .js files dynamically. What is the best way to achieve this, considering that I found that Jinja functions and variables are not working in the .js file?

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

Python

That's not helpful. And a reason for a warning from different perspectives.

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

Python

What, specifically, is the problem?

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

Python

defined a simple function, def, a list, and a dictionary — in every case it printed the value correctly, because Python's print() works on any object type by converting it to its string representation internally, so the function doesn't care what kind of data x holds 🐍. However, when I called show() with no arguments at all, Python raised a TypeError: show() missing 1 required positional argument: 'x', and when I called it with two arguments like show("hello", "world"), it raised TypeError: show() takes 1 positional argument but 2 were given — this happens because while Python is flexible about the type of data a function accepts, it strictly enforces the number of arguments based on the function's signature, and since x has no default value, exactly one argument must be supplied, no more and no less; if you wanted to allow a flexible number of arguments, you'd need to use a default value like def show(x=None): or a variadic form like def show(*args): instead 🛠️.

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

Python

Hi everyone! I want to learn Python, but I’m not sure which videos, books, or other resources I should use. I’d really appreciate it if you could guide me and recommend some good resources for learning Python. Thanks!

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

Python

Python groups in other languages
(⚠️Not managed by us ‼️)

Arabic @arabipython
Azerbaijani @azepug
Chinese @pythonzh
French @python_francais
German @pythonde
Hebrew @pythonisrael
Tamil @pythontamilcommunity
Indonesian @pythonid
Italian @python_ita @pythonita
Kazakh @python_kz
Malaysia @pythonmalaysia
Persian @pyfarsi
Portuguese @pythonbr
Russian @ru_python_beginners @ru_python @python_scripts
Spanish @PythonEsp
Swahili @python_eafrica
Turkish @python_tr
Uzbek @python_uz

If you have an active and well managed group that you want to be listed there, ask in the Meta group, link in the rules page.

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

Python

Please don request him to send you things, He must share it here

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

Python

If it isn't working and you don't have any errors, then it isn't running or you haven't found the errors.

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

Python

Even i didn't any errors

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

Python

Please my friends i need someone helping

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

Python

its not particularly hard to do, and anything else is a hack at best

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

Python

If you want to host something yourself you'll have to learn these concepts

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

Python

You'd use tmux for development and systemd to host a production app.

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

Python

I have a question about passing data from Python to HTML hidden fields. When inserting values from Python into my HTML hidden fields, I sometimes need to pass the correct data type. For example, if I have a variable like money = float, I need to send it, but HTML stores it as a string, so JavaScript will try to convert it into an int and use it.

Additionally, consider this regular expression:

var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

In this case, how should I take it from Python's backend and pass it into JavaScript, given that this is not a simple string type in JS? Also, if I want to pass this via a Python context_processor, what should the data type be in Pydantic's pydantic-settings?

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

Python

You pass it to HTML document and grab its value with JS 🤷‍♂

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

Python

Have you opened the interactive prompt?

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

Python

Please refrain from sharing content nobody has asked for.

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

Python

Any that you have available, when knowing nothing any material is an option

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

Python

Can anyone help me with this


At the Python interactive prompt, write a function that prints its single arguunent to
the screen and call it interactively, passing a variety of object types: string, integer, List,
dictionary. Then try calling it without passing any argument: What happens? What happens
when you pass two arguments?

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

Python

https://divyajyotidas15.substack.com/p/journey-of-http-packets-end-to-end?r=26jw99&amp;utm_medium=ios

Nice Article on http packet flow from client to server.

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

Python

This is not a Python specific question, please delete your offtopic message, move to @PythonOfftopic and ask there.

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

Python

Sure I can help Send me the code you're trying to run and tell me what happens when you run it Also let me know which Python version you're using

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

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

When I write the code inside the pycharm or vs code python is not working

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

Python

hi guys i have to put a little bot that use apis to send some results via telegram, can you please suggest to me a free hosting to run h24 this bot?

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

Python

Look up how to create a systemd service and then use that with your Python code

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

Python

tmux is (basically) designed to let you keep a shell session even if you close your terminal. You can then open another terminal and reattach to the same session (because it carries on running even if you're not attached to it). This works nicely for your uv run use case, for dev work.

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

Python

so there is two type of things i need to setup, to keep running 1 things always correctly?
what what these, tmux , systemd.
thought i never used this and knew nothing about this, are you saying this to use to host real python app ?

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