Re: is mypy failing here

2022-11-24 Thread Kirill Ratkin via Python-list
Hi Robin, mypy --strict gives you detail info. On Thu, Nov 24, 2022 at 10:05 +, Robin Becker wrote: > I haven't used dataclasses or typing very much, but while playing about I > found this didn't give me an expected error > > (.py312) robin@minikat:~/devel/reportlab > $ cat tmp/examples/tdc

Fail 3.10.8 version installation on Windows 11 21H2

2022-10-12 Thread Kirill Ratkin via Python-list
Hi All, Do anyone face issue like in log below? I got last installer (3.10.8) and try to install it 'for all users' with downloading precompiled (pdb) files. And installation fails saying permission error. Installer says downloading error in the log. I repeated it three times with same re

Re: dict.get_deep()

2022-04-04 Thread Kirill Ratkin via Python-list
Hello, Yes, I misunderstood as well because started to think about pattern matching which is good but this is not subject the question was about. Sorry for my mistake. Because question was about 'builtin' function which means stdlib function implemented in python itself or even in C. It

Re: dict.get_deep()

2022-04-03 Thread Kirill Ratkin via Python-list
To my previous post. It seems 'case if' should help with types: case {"users": [{"address": {"street": street}}]} if isinstance(street, str): :) // BR 02.04.2022 23:44, Marco Sulla пишет: A proposal. Very often dict are used as a deeply nested carrier of data, usually decoded from JSON.

Re: dict.get_deep()

2022-04-03 Thread Kirill Ratkin via Python-list
Hi Marco. Recently I met same issue. A service I intergated with was documented badly and sent ... unpredictable jsons. And pattern matching helped me in first solution. (later I switched to Pydantic models) For your example I'd make match rule for key path you need. For example: data = {

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
Hi 30.03.2022 21:44, Larry Martell пишет: On Wed, Mar 30, 2022 at 2:40 PM Kirill Ratkin via Python-list wrote: Hi again, I changed a bit your example and it works as you expected I hope. import asyncio async def long(): for i in range(100): await asyncio.sleep(10

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
Hi again, I changed a bit your example and it works as you expected I hope. import asyncio async def long():     for i in range(100):     await asyncio.sleep(10)     print("long is done") loop = asyncio.get_event_loop() task = loop.create_task(long()) print('after asyncio.run') loop

Re: calling a function asynchronously

2022-03-30 Thread Kirill Ratkin via Python-list
Hi, You can use asyncio.create_task and gather results. See docs - https://docs.python.org/3/library/asyncio-task.html But think twice what you want to do in async task. Do you use synchronous requests to database? If yes it will blocks eventloop... If you use Django it makes sense to use someth

Re: How to detect an undefined method?

2022-03-27 Thread Kirill Ratkin via Python-list
I just started to think from your example with method 'err' of logger object. In this particular case you can check method 'err' exists or not before call this. But if you mean general case ... . If for example I use some library which uses another library and someone just 'typo' there ...

Re: How to detect an undefined method?

2022-03-27 Thread Kirill Ratkin via Python-list
Hi You can get all methods of your object and check the method you want to call is there or not. |methods = [method for method in dir() if callable(getattr(, method))] if 'method_you_need' in methods: . // BR | 27.03.2022 12:24, Manfred Lotz пишет: Let's say I have a Python app and have u