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

the last line:

// res should be Config but not pycharm dont recognize

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

Python

I have an issue with my code, from this


def create_functions():
functions = []
for i in range(3):
def f():
return i
functions.append(f)
return functions

f1, f2, f3 = create_functions()
print(f1(), f2(), f3()) # I Expected: 0 1 2, Actual: 3 3 3


Why does i=iwork? (Default args are evaluated at function creation.)

How does thiss relate to lambda in loops? Same issue

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

Python

Have you done some searches on google regarding that? It is a basic conceot and should be there tons of articles and materials to learn

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

Python

Extension where or for what?

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

Python

hi, i have a problem with typing, could someone help me to solve this problem:

https://www.codebin.cc/code/cmd6bm9re0001i3032e4actvx:4biBzeifDz3CZHnBfK8isz5GQDwJRQT5LSACdBwUj3j8

repo: https://github.com/andrew-ld/LL-mtproto

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

Python

Anyone give me the solution for template doesn't exist error in django

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

Python

So you didn't look at it. The official tutorial is very easy to follow, give it a chance

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

Python

The official documentation has the best tutorial you can use to start

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

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

Hey , I have modified a function but it’s working for the future inputs but not working for the existing ones which one is in my db

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

Python

If you define your base class as a protocol, then every class that implements that protocol should include all the functions (methods) defined at protocol

In this usecase, ABS is maybe a better choice as it gives you apstract methods that need to be defined by user supplied class, and a "general" - all instances methods (like run or get_name)

In your usecase, inheritance is better choice (i think)

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

Python

https://realpython.com/python-protocol/

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

Python

Yea yea, surprised something this nit picky was thought of lol

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

Python

As @razorblade23 pointed thats a good solution but, also consider to sue a protocol instead of a base class to do duck typing

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

Python

So you don't want to import it?

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

Python

can someone tell me where can I find data engineering project like real-time kind of ETL process to add on resume for free with datasets and all?
to do and learn and not just for show. would have tried myself but actively looking for job so

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

Python

you said "could someone help me" - what help exactly do you need ?

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

Python

How to use lambda function is anyone aware

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

Python

Guys
What extension do yall use
I want it to be interactive so it supports input()

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

Python

That's what I was thinking but it's cool to know what's possible. Ty you and Charly for the help

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

Python

Ok
I will try again
Tnx

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

Python

I find that a little challenging to understand.
Generally all documentations.

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

Python

Where to start learning Django with a starting point?

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

Python

Could you help me with this problem

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

Python

That's normal to import something "just for types" and it's usually no need for tricks with if TYPE_CHECKING. It's meant for solving real problems, not creating noise.

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

Python

I somewhat understand this. Seems crazy though you can pick and choose like that but i guess it makes no difference at runtime

So my base consumer has an abstract method process the user needs to implement so they send the data wherever they want and 2 other normal methods run and get_name

If i make it so the protocol is defined by those methods and attributes, or i guess even just process and run since that's what i expect in my code to be implemented, the user can build whatever class they want

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

Python

Sorry now you lost me

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

Python

And this also avoids issues with imports in some cases

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

Python

You mean something like this?

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from package.things import Thing

def func(it: "Thing") -> None:
...

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

Python

Well I'm only importing it for the type hinting. I don't actually use it in the code at all

async def run_pipeline(self, consumers:List[BaseConsumer]):

Just seems like a weird design choice since you can't really depend on imports to actually be used in the module then. Something could be imported just for types

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