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

I picked up "Automate the boring stuff with python" and I was reviewing the basics again.
Chapter1-Chapter8.

# book refrence:
while True:
print('Who are you?')
name = input('>')
if name != 'Joe':
continue
print('Hello, Joe. What is the password? (It is a fish.)')
password = input('>')
if password == 'swordfish':
break
print('Access granted.')
......
#This is my attempt to do it with less lines:

while True:
name = input("Enter your name: ")
if name != "Joe":
continue
password = input("Enter your password Joe: ")
if password == "dumbass":
break
print("Access granted!")

The problem I am facing is that my code reveals the second line after 'continue ' even tho the password is wrong.

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

Python

This is inline generator without any logic on data. If you want to apply logic, better to create with proper yield statement.

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

Python

Tuples defies with multiple values with comma separated.

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

Python

First expression is for list comprehension and second one is for generator.
To create set, you must define with set keyword. By the way, () is symbol of tuple.

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

Python

https://pythonbooks.org/free-books/

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

Python

Hello everybody, could you please suggest a comprehensive course for Python ?

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

Python

num1 = int(input("le premier sifre : ..."))
num2 = int(input("LE deuxieme sifre : ..."))

operation = input("rentre votre operation ( +, -, *, / ) : ...")


if operation == "+":
print("sonucunuz : " , num1 + num2)
elif operation == "-":
print("sonucunuz : " , num1 - num2)
elif operation == "*":
print("sonucunuz : " , num1 * num2)
elif operation == "/":
print("sonucunuz : " , num1 / num2)

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

Python

Can you teach me Python?

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

Python

Lets not spam this group anymore, switch to Discord please

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

Python

It would be really nice if you would open an issue on Github (or two) stating all of these bugs you found / think you found.
So when i fix them, you get credited.

Its very easy to do. Just follow the first example in this document
https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-an-issue#creating-an-issue-from-a-repository

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

Python

Generators do not work yet
I though we established that

And if you knew what generator is, you would knew that you can call next() on it to produce a value
vivekvjnk/understanding-python-generators-the-power-of-yield-and-state-management-382faa48e761" rel="nofollow">https://medium.com/@vivekvjnk/understanding-python-generators-the-power-of-yield-and-state-management-382faa48e761

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

Python

see as you say i found and started using this library, lastly all before thigns works, but it got stuck when i use the di to do real database crud operation, there it say, but still i found the a fun whihc do :
yield session, this function not yeield the session but it return a generator, and thats why i cannot perform any crud functions there, i will try to raise one issue in the repository with all the things,

def get_session() -> Generator[Session, None, None]:
with Session(engine) as session:
yield session

but i found my code fails at this line,
results = self._session.exec(statement)
by saying
AttributeError: 'generator' object has no attribute 'exec'
i spend all the day and night not solving any solutions, as you say this will works like same as fastapi yield also, but it not works, what can i have to do, i integrate this library but lastly this one problem is not solvable, 😢
it so painful, what can be the solvable solution for this?

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

Python

as you say to impliment like for my use case i found this is working,

@login_manager.user_loader
def load_user(
user_id: str,
) -> FlaskLoginUser | None:

from flask_di import Depends

user_repository: UserRepository = current_app._resolve_dependency(
Depends(user_repository_provider)
)

obj_domain = user_repository.get_by_id(user_id)

if obj_domain is None:
return None

obj = FlaskLoginUser(obj_domain)
return obj

i found maybe this is working, but i have a problem maybe:
see is this any problem,
first of all as from flask import current_app does not know about the _resolve_dependency, so any easy way it will shows current_app._resolve_dependency with type sugerssion in the vs code?
2nd ly is a problem see when i do 'user_repository: UserRepository' still as the current_app dont know about this return type it still say user_repository is a UserRepository | Unknown

Thats why it cannot be solved easily, how i can solve this, can you solve by chaning somethign in ur library, or i need to do how in my code?

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

Python

i wish i could do this type of things like other do.
i am really learning more about di and so on and then come back with you

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

Python

But it is
Flasks request is in both of these, it should work fine

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

Python

Naukri Campus is hosting the India's biggest skill contest to help you stand out to recruiters, win prizes, and more! Don't miss out, enrol now here:
https://www.naukri.com/campus/contests/young-turks-skills-assessment-test?action=enrol&referral=e2000105-rY4PEHZ-pseu&uapp=8010&utm_source=share_pwa&utm_medium=referral

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

Python

yaa it was very basic i was so glad to recall this, but still i need to know a little more about generator making 💚

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

Python

yaa yaa sorry, i need to ask why not tuple 😅

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

Python

squares_list = [x * x for x in range(1000000)] 
squares_gen = (x * x for x in range(1000000))

Why first one is list second one is generator not set? which part say it to work like yield here? 💭🤔🧠

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

Python

like a PDF or something

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

Python

I know a little bit.

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

Python

Check out @PythonRes, a channel for Python resources - video courses, pdf books, tutorials and other info to help you learn Python.

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

Python

i will give my all code example and just ask there with proper traceback?
will this disussable in ur ledger

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

Python

so actually the problem is what i will stated with my code example:-

is this the yield session not working here in flask-di, as i see in fastapi they just has yield session, and in the fun parameter variable:sessionDep lile this works so perfectly, so my main point of open a issue to saying this to work like fastapi

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

Python

what establishment, should this yeild sesion will not work in this di-flask, i found it always return generator not the context manager 😢:
ok let me check these thigns btw 😴

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

Python

Just type cast it into whatever type you want/need
https://docs.python.org/3/library/typing.html#typing.cast

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

Python

i think if the current_app like things is gives by di_flask it would easy like this same or what as this curretn_app._resolve_dependency is the only problem without any return type like this so it always shows Unknown and shows problem?

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

Python

https://github.com/razorblade23/di-flask/blob/master/src/flask_di/core.py#L86-L114 so you just say to make a more public interface of this methods, this will so simple i can also do this, should i cahnge the library and make a methods and call this private from that, but as the .venv/lib/flask_di, is a library code even i will edit this this not tracked by github, and as a result later this will not work, so no way to use until then, can i change this and then how i can send to github so that you can check that?

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

Python

I did not copy pasted fastapi Depends

So my library is not the same as the one from fastapi
It aims to be, but its far from it.

Raise an issue on Github if you think something is not implementated but should be (like this thing with generators)
Its one step more to becoming developer

Participate in other people projects, learn from them

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

Python

pls i am newly learnign integrating this library, and i am just trying to use like this, ,
i want to point as this say, the di-flask not performs cleanup, -> what about this, as fastapi docs say after this response done it will clean, here is this also works or not?

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