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

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: 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.

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')

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

Re: How to detect an undefined method?

2022-03-27 Thread Kirill Ratkin via Python-list
d such error. I guess there  is not warranty to detect such sitations in huge codebase. It's python dynamic nature. May be dynamic checkers can help in such situations ... 27.03.2022 20:07, Manfred Lotz пишет: On 3/27/22 18:57, Kirill Ratkin wrote: Hi You can get all methods of your object a

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

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Kirill Ratkin
Hi, As far I know there is tool rpmvenv (https://github.com/kevinconway/rpmvenv). Try it, maybe ot helps. 04.03.2022 16:03, Hartmut Goebel wrote: Hi, How can I make installing a virtual environment honor DESTDIR? How can I install a virtual environment in $(DESTDIR)$(PREFIX), which

Re: Long running process - how to speed up?

2022-02-19 Thread Kirill Ratkin
Hi, How I understand your script starts another script and should wait until second one completes its job. Right? If so you have several options depend on how your first script is written. If your script is async then ... there is good asyncio option proc = await

Re: Unpacking lists in a f string

2022-02-09 Thread Kirill Ratkin
Hi. Try this: f"foo {','.join([f'{a} {b}' for a,b in list(zip(l1,l2))])} bar" 09.02.2022 21:13, Paulo da Silva пишет: Às 02:17 de 09/02/22, Paulo da Silva escreveu: Hi! Let's say I have two lists of equal length but with a variable number of elements. For ex.: l1=['a','b','c']

Re: Why There Is No Python Compressed Archive or Binaries ?

2022-01-17 Thread Kirill Ratkin
Hi Grant Hmmm...  definitly you are right in particular solution. But Ok, let me show example. I often use Go in parallel with Python and sometimes I switch between Windows/Linux also. On both systems I just download Go toolset as tarball/zip file and unpack in place where I like. The

Re: About Python Compressed Archive or Binaries

2022-01-17 Thread Kirill Ratkin
Hi, Yes, this is good question for Windows users. Of course, you can download installer exe-file -> do installation -> pack directory with python interpreter to zip (for example, or 7z) -> copy archive file to another place/computer and unpack. But it will not work out of box because

Re: symlinks with python3 http.server.CGIHTTPRequestHandler

2022-01-11 Thread Kirill Ratkin
Hi Maybe you have some restrictions on file system level. Some selinux for example. I try similar steps on my local 'linux mint' and ... linked script is called my http.server without errors. Here is my 'tree': ├── cgi-bin │   └── test.py -> ../orig.py └── orig.py All files are

Re: Script profiling details

2022-01-10 Thread Kirill Ratkin
Hi Joseph, ** Did you try scalene profiler? Recently I solved a similar problem and scalene really helped me. ** It creates a well-formed HTML report, and you can optionally enable/disable report about a code outside your project, for example - standard library. **

RE: Gunicorn - HTTP and HTTPS in the same instance?

2022-01-08 Thread Kirill Ratkin
Hi. You probably can solve issue on Gunicorn side. But afaik better solution is to use http proxy before Gunicorn. This proxy accepts https connection and proxy requests to Gunicorn instances as plain http. This approach gives you: a) Monitoring on network layer (tcpdump/wireshark shows you

Re: How to make a type of a C extension compatible with mypy

2022-01-01 Thread Kirill Ratkin
Hi Marco, It seems issue is about file py.typed and PEP-561. As I understand issue's description you don't need to do it in C but some work in Python files need to done. Maybe this link helps (https://blog.whtsky.me/tech/2021/dont-forget-py.typed-for-your-typed-python-package/) // BR (KR)

Re: using OpenGL on windows 11

2022-01-01 Thread Kirill Ratkin
Hi! Your machine remembers but you probably use different virtual envs. PyCharm, as I remember, creates its own venv (per project maybe). It's better to remove python interpreter installed from MS application market and download python installer from python.org. Install it as user or