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

ok i will do making the project first 💚 thanks for you support btw

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

Python

as the SessionDep's di will be sit in top of routes.py's function, is not this bad as my reouts is using the di-flask library

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

Python

Stop thinking
Work

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

Python

Actually, sqlalchemy docs are one of the best
There is a great deal of information there and the library does support quite a lot of things.

Make sense that docs are dense and filled with content.
You need to READ IT
I dont care (or anyone does) what you think of them

They are there - read them
Practice from them

Stop wasting everybodys time and learn things or not

Its all up to you

Now stop sending messages and learn

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

Python

Stop with DI
Its over your head

Stick with simpler things untill you get it

Stop trying to be someone you are not. Stop trying to run before you know how to walk.

Just drop this DI thing and forget about FastAPI and SQLModel

Start with basics, then move on

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

Python

all i understand but say atleast in the Depends from flask-di where i can say the cache, multiple_depends ie Dependencies, where is those keywords args not stated in the code i write, how i can add those which has by fastapi's Depends?

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

Python

This i give a lot lot lot research to undersand and use this library, first i read the all things i can know about dependecy injection, then i read about all the fastapi's Dependency, and then i understand that in fastapi there are some things in the Depends(........)
1. Example, when there is sub-dependencies like dep_a called by dep_b and it is called by dep_c, then there in the routes fun i just give dep_c and it call the both by itself, but in the Depends() i call from the flask_di library where there i cannot see this not any documented in the code or nowhere.

2. when one di_function is called many time in one request circtle the value got cached this, i could do like cache=True/False in fastapi here, in flask can you do say how i can do this,

3. try: yield session, finally: session.close()
like this concept fastapi docs say to use, where there is

scope: Annotated[
Literal["function", "request"] | None,

is this what applied in the flask_di library? what here happens how i can know when it do the cleanup.

i really tried to use these thigns in my flask so that i can do easily codes of those thigns and make webapp with those di, things will i use this 3 thigns how???

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

Python

but i will learn those one day

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

Python

i also tried to use the flask-sqlalchemy like thing, but, i always think it a more hardwork to learn a full new library to do some crud operations , and it looks so problamatic not easy docs like sqlmodel have one.

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

Python

What the hell are you talking about?
Just give up from DI, use flask-sqlalchemy and be done with it

Why are you so persistent on something you still have a long way to understand.

You are mixing up a lot of concepts and that is just spinning in circles, nothing good comes out of it.

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

Python

One thing I understood after a lot of brainstorming, btw 😅
So, like in FastAPI route functions, we can define things like sessionDepCommonParametersDep, etc., where they ultimately come from Depends(function_name).
Those dependencies just sit there as part of the route function's parameters. When a request comes in from the browser, FastAPI starts resolving the dependencies required by that route.

so once the dependency is executed and its value is generated, FastAPI injects that value into the corresponding parameter of the route function. Then the route function executes using those resolved dependency values.

So, basically:
Request → resolve dependencies → dependency functions get their values from the request → dependencies return their results → FastAPI injects those results into the route function → route function executes.
Is that understanding correct?
and thsi will be fully same if i will use the di-flask and use those in the fun parameters, so i can use many Depends in my fun paramters will this no problem at all and i just need to use all in only def funcion, not async def and then i am fully ok to use the library to use the sesion thigns?

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

Python

Otherwise the bots will slap you

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

Python

Right, someone had the bright idea to make two bots

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

Python

i mentioned his razorblade message i dont know how it happened, what warnign of 1/3 i get? by the way i lost the big message i wrote last 5 minute long i typed the message and the bot delete the message 😅😢,

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

Python

Have you any repo or code example written with di-flask's library codes?

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

Python

Just stop or i will start reporting you
Figure it out yourself, we are not here for step by step instructions or holding hands.

If you dont have a specific error or specific question about python, go Google and learn things

Once you have a specific question to ask, come back

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

Python

Suppose a user want to register so after successfull verification i will store his data of email and password (not mandatory) so first my app will get the request with the email_id as string from the browser,

@auth_bp.route(
rule="/register",
methods=["GET", "POST"],
)
def register():
...

so as the DDD say rather than chekcing the id passwrod, user existance in db and so on in the routes.py's register function i will call anotehr functions or class method right?

See what i get,
After i get the email id i will call regiseter_user fun from service.py module, which will call UserRepository(session-> gives by SessionDep by flask_di) and call .is_exists(email_id) methods form this UserRepository.
Then based on this it will call a OtpRepository.send_otp(reason=login/register), and based on the otp send successfully or not it will depends and then it will say appropriately if the mail is banned temporarery, suspended, email server down /choose another method.
so i will do those so where does domain, application will be there, as i understand the service layer, and then i also thought service layer and applicaiton layer are same or not i think yes?
so i will total how many differne type of modules, domain-> service -> otp_service&database_service -> infrstructer(called by protocle instance) am i right now

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

Python

Now i think to start making my project structer properly with DDD, so that now even i use sqlalchemy later i can easily switch to sqlmodle or di like things for this as you says in past, i will need to separate responsibility into different moduels and functions(mostly by class methods) right?
see a hypothetical example.

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

Python

i also wish to start new things, but the repo i am using with Full DDD pattern there is a lot of overhead to change all the things to use sqlmodel to sqlalchemy(which docs are fully unclear and noob docs), and i checked sqlmodel db works with relationship and so on the problem i just there if i write normal databse crud function in with session block with sqlmodel then there is no need to worry about di thing right???

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

Python

That's you open my one of the eye of learning 💚💜❤️
i appreciate ur helping 🤜🫸🫵

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

Python

Just stop
Stop writing walls of text and stop questioning, and get to work

Reading will not do anything if you dont practice and experiment in your own code

If you do it wrong, it wont catch on fire (most od the times) - it will just be an error
Which you can google and find out more

This constant " i tried" and "i really really want", and things like that dont lead anywhere

This is my final answer to you

Use flask and flask-sqlalchemy
Build 3 apps with that

Then you can (maybe) go into something depeper

Now please stop sending messages, and start learning and practicing.

I am not answering any of those anymore
And for the last time.

Coding is not easy - it takes a lot of time, effort and brains.
If you are unwilling to learn new things (for instance flask-sqlalchemy - or even sqlalchemy (which all of these are based on)) then how can you expect to do anything new?

You have not even scratched the surface

So go learn and evolve yourself, and stop procrastination (google it if you don't know what it means)

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

Python

not like this, those are from fastapi but i want to use in flask

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

Python

I have no words 🤷‍♂

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

Python

i understand, but all moments i read one new docs i think i am done with this and i am just capable to use the things but again new problem or concept comes quickly

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

Python

@razorblade23 one thing i understand from ur idea that in di thing.

class UserService:
def __init__(self, repository):
self.repository = repository


this is the di we use but for fastapi i have the Depends() only this things, which just help us to wirte so easily.

So what i will do actually like in my case like calling mail_service, payment_serbice i will erite those in the Depends or externally?

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

Python

ooo its so complicated thigns 😅

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

Python

Make sure you wrap any decorator names in code

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

Python

ℹ️ ‎Nandu [8176162859] already has no warnings.

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

Python

You cannot mix sync and async code
Flask being sync, you cannot have async functions (without spinning up your own async loop)

And that function returns a dictionary, and you can use it just like in the examples so i do not see any problems there.

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

Python

One Request to you, from the reading and reading from many places about fastapi, di and so on i found one issue, is this issue or not...
As i read a docs of fastapi, it say with a code example demo:

async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
return {"q": q, "skip": skip, "limit": limit}
CommonsDep = Annotated[dict, Depends(common_parameters)]

@app.get("/items/")
async def read_items(commons: CommonsDep):
return commons
@app.get("/users/")
async def read_users(commons: CommonsDep):
return commons

fastapi docs part here say
And you can declare dependencies with async def inside of normal def path operation functions, or def dependencies inside of async def path operation functions, etc.
It doesn't matter. FastAPI will know what to do.

so like when i will use ur library in my flask app what is the restrictrion there, as i will use normal def function and if i will use the Dependency function there in async way will it fully work or not as this is not anywhere so i ask you, will it beheave like fastapi in all the 2 cases?

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