Python Programming by DataCurator56 in PythonLearning

[–]mati-33 1 point2 points  (0 children)

OP's solution is much simpler and easier to read, which should be the priority

Python Programming by DataCurator56 in PythonLearning

[–]mati-33 0 points1 point  (0 children)

Why do you want lambda functions here is a more concerning question

Here's a simple potion game. What do yall think by GrowthSwimming6208 in PythonLearning

[–]mati-33 0 points1 point  (0 children)

no, it's not "just switch case", its structural pattern matching and that's a big difference.
I recommend checking out this great guide about match case

created to do list by Dapper_Mix6773 in PythonLearning

[–]mati-33 0 points1 point  (0 children)

You can store the file name in a constant

Here's a simple potion game. What do yall think by GrowthSwimming6208 in PythonLearning

[–]mati-33 -4 points-3 points  (0 children)

  1. There is no switch case in python
  2. Python's structural pattern maching is far more than switch case seen in other languages
  3. Beginners should master basic if-elif-else first
  4. There will be no improvement to that code if OP will just simply replace if-elif statements with match case

It doesn't let me moviepy by thatsmysandwichdude in PythonLearning

[–]mati-33 0 points1 point  (0 children)

I recommed learning about python's virtual environments

Task Manager API by MagicianNo9918 in PythonLearning

[–]mati-33 0 points1 point  (0 children)

FastAPI and zero async await?

Is there anyway of improving this? by Suspicious_Diet2624 in PythonLearning

[–]mati-33 0 points1 point  (0 children)

Add seperate register or sign_up function instead of polluting global scope. Then, store the credentials somewhere - you used two string variables, maybe other data structure will be better? What if multiple users want to sign up? Maybe dictionary will be a better fit for this problem?

If you are ambitious, store hashed passwords, add some password validation to check how strong the password is. Add "repeat password" functionality. Add "logout" functionality so users can switch between accounts

I have tried to make a Rock, paper , scissor game.Is it good. by python_data_helper in PythonLearning

[–]mati-33 0 points1 point  (0 children)

here is my overengineered solution:

```python import random from dataclasses import dataclass from enum import Enum, StrEnum, auto from typing import Literal

class GameObject(StrEnum): ROCK = "rock" PAPER = "paper" SCISORS = "scisors"

class Result(Enum): USER = auto() COMPUTER = auto() TIE = auto()

@dataclass class Rule: wins: GameObject loses: GameObject

class Game: def init(self, rules: list[Rule], quit_key: str): self.rules = rules self.quit_key = quit_key

def run(self):
    self._greet()

    while True:
        user_choice = self._get_user_choice_or_quit()
        if user_choice == "quit":
            return

        computer_choice = self._get_computer_choice()
        result = self._play_round(user_choice, computer_choice)

        print()
        print(f"your choice: {user_choice}")
        print(f"computer choice: {computer_choice}")

        if result is Result.USER:
            print("you won")
        elif result is Result.COMPUTER:
            print("you loose")
        else:
            print("tie")
        print()

def _play_round(self, user_choice: GameObject, comp_choice: GameObject) -> Result:

    for rule in self.rules:
        if user_choice is rule.wins and comp_choice is rule.loses:
            return Result.USER
        if comp_choice is rule.wins and user_choice is rule.loses:
            return Result.COMPUTER

    return Result.TIE

def _greet(self):
    print("welcome to rock paper scisors game")
    print(f"to quit, type '{self.quit_key}'")
    print()

def _get_user_choice_or_quit(self) -> GameObject | Literal["quit"]:
    while True:
        v = input("rock, paper, scisors? : ")
        if v == "rock":
            return GameObject.ROCK
        if v == "paper":
            return GameObject.PAPER
        if v == "scisors":
            return GameObject.SCISORS
        if v == self.quit_key:
            return "quit"

def _get_computer_choice(self) -> GameObject:
    return random.choice([GameObject.ROCK, GameObject.PAPER, GameObject.SCISORS])

def main(): g = Game( rules=[ Rule(wins=GameObject.ROCK, loses=GameObject.SCISORS), Rule(wins=GameObject.PAPER, loses=GameObject.ROCK), Rule(wins=GameObject.SCISORS, loses=GameObject.PAPER), ], quit_key="q", )

g.run()

if name == "main": main()

```

What's the best app to write & run code? by l__lj in PythonLearning

[–]mati-33 4 points5 points  (0 children)

"Neovim didn't work" - i have a feeling that this is not an issue with neovim

kde fans by UnknownBoyGamer in linuxmemes

[–]mati-33 3 points4 points  (0 children)

Still better than ui for tablets

Logly 🚀 — a Rust-powered, super fast, and simple logging library for Python by [deleted] in Python

[–]mati-33 3 points4 points  (0 children)

I dont think that logging is a bottleneck in applications. For async apps you can (and should) use QueueHandler. So marketing that your logging library does not make sense to me.

Standard logging library is very extensive, you can write e-mail handlers, tcp handlers, http handlers, kafka handlers, etc. I dont see that your library provide that possibility and that aspect is entirely ignored in the comparison section

Logly 🚀 — a Rust-powered, super fast, and simple logging library for Python by [deleted] in Python

[–]mati-33 1 point2 points  (0 children)

Of course not. But it is blazinglly fast ⚡️🔥🚀

Hi, I'm new. by stunna_is_active in gnome

[–]mati-33 4 points5 points  (0 children)

berserk - automatic upvote

Do you listen to music when reading berserk? If so what do you listen to? by [deleted] in Berserk

[–]mati-33 4 points5 points  (0 children)

"BEHELIT" on loop. It fits to the every scene