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

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

nohup uv run main.py & Then you should be able to close your SSH session.

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

Python

No, if your VPS reboots, you'll lose your tmux session. But if you use systemd, that'll take care of starting it again on boot.

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

Python

Or just use nohup.

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

Python

i though if i run the command:
uv run main.py
in the terminal of the vps then even my laptop's or termux's termianl app got closed but the python process should to run in the vps, so the port should to open and this should to response to outer request over https.

But i found randomly sometime after a break the python app which was runnign just stop anyhow, i checked others things and got confirmed that my vps never got reboot in the meantim, but still the uv run main.py got stopped, is this because could be my vps is low configuration?

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

Python

I have a basic Flask example repo that I copied to a VPS. In the repo, my Python main.py code looks like this:

if __name__ == "__main__":
app = create_app()
app.run(
host=settings.app.host,
port=settings.app.port,
debug=settings.app.debug,
)


On the VPS terminal, I navigate to my directory and run:
uv run main.py

As a result, the app starts running on a port (e.g., 9999), and I can access the website from other devices via ip_addr:9999.

However, even though the VPS provider's dashboard shows my system has been running for over 10 hours, the app stops working after a short time (10 minutes, 1 hour, etc.). I noticed that other processes are still running, but this specific port closes automatically. I then have to go back to the VPS and run main.py again.

Is this expected behavior in reality? How can I keep my Python app running on this same port without it stopping? or i am missing something here 🐍🚀

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

Python

By the way, my English is not good, so I use Google Translate, which may have problems with phrasing and such.

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

Python

I think he is copy pasting answers from Ai. but I'm not sure

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

Python

yeah, telegram go brr.
also, there's the case for yield and map() here, but feels out of scope lol

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

Python

what a shitty fix ngl

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

Python

The Answer:
The correct output is **B: [4, 4, 4, 4, 4]*Why? (The "Late Binding" Trap)p)**
In Python, closures look up the variable name in the outer scwhen the function is calleded**, not when it’s defined. By the time you call the functions in the list, the loop has already finished, and the variable i is left at its final value: 4. All your function objects are referencing the same i.

**The Professional Fix:**
To capture the value at the time of definition, you need to "freeze" it. The standard way to do this is by default argumentgument**:

def create_multipliers():
multipliers = []
for i in range(5):
# By setting i=i, we capture the current value
# of i as a local variable for this function instance.
def multiplier(x, i=i):
return x * i
multipliers.append(multiplier)
return multipliers

Now, each function maintains its own snapshot of i, and the output will be the expected [0, 1, 2, 3, 4].

*This is a classic "gotcha" in Python. Understanding scope is what separates a beginner from a production-ready engineer.*

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

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 ?

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

Python

i checked nohup > & like this, i think maybe my cpu is 1 vCpu that' why it kills my python process there

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

Python

i never listen this concept,but what is the background of this topic, is this like even my vos got reboot this tmux will help to run all python thing?

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

Python

Well, my first guess is that the process is killed with the SSH connection. If you want exactly this command to keep running, you need to use tmux on the VPS, not on the client (laptop). And the way you'd actually do it in production is with systemd services.

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

Python

Could have have anything to do with the SSH connection being disconnected?

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

Python

This group is to help you on specific issues you have on YOUR code, so you have to show the code you wrote and explain where and why you are stuck... as simple as that

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

Python

Yes, I will try to post spring content from now on. But I don't think it matters where we copy and paste from, as long as we learn something. This post was like this, otherwise I will try to find the best programming tips and skills and post them here.

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

Python

Your copy and paste doesn't look so good.

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

Python

depending on context i would go with either of these, default argument binding just seems like a confusing hack to me tbh

import functools

def multiplier(x, i):
return x*y

def create_multipliers():
return [functools.partial(multiplier, i=i) for i in range(5)]

or
def create_multipliers():
def make_multiplier(i):
def multiplier(x):
return x * i
return multiplier
return [make_multiplier(i) for i in range(5)]


intent is far more obvious with these

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

Python

❗️ Message from ‎Jafar Salimi [532744334] was reported to the admins.​​​​​​​​​​​​​​​

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

Python

cuz it's capturing i by reference, not by value

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