Quantcast
Channel: User Louis Maddox - Stack Overflow
Browsing index pages (56 articles)

Answer by Louis Maddox for Asynchronous requests with Python's Requests

I second Uri's suggestion to use HTTPX, but I often use it in a different way so am adding my answer.I personally use asyncio.run (introduced in Python 3.7) rather than asyncio.gather and also prefer...

View Article


Comment by Louis Maddox on What is the best way to dewarp pages with Python?

Hey, page-dewarp maintainer here, apologies your question didn’t receive a reply for 15 months! I’ve put a lot of effort into improving the docs and I hope my belated reply in this issue resolved it...

View Article


Answer by Louis Maddox for Ho to get final SQL query from diesel

It will vary by dialect but here is a little demo of 'compiling' Diesel ORM to SQL(ite)Self-contained Rust script: https://gist.github.com/lmmx/3a712c79f55d84971addea08d4dee953use...

View Article

Answer by Louis Maddox for pathlib.Path().glob() and multiple file extension

You can use a function to filter a recursive glob with pathlib.Path.rglobhttps://docs.python.org/3/library/pathlib.html#pathlib-pattern-languagelist(filter(lambda p: p.suffix in [".xls", ".txt"],...

View Article

How to match comments on an image using kix anchor (or not) in Google Docs

It's possible to retrieve elements of an open Google Docs document, starting fromDocumentApp.openById(doc_id, folder_id)but the comments on a document are retrieved through the Drive API, with...

View Article


Answer by Louis Maddox for Does Polars support creating a dataframe from a...

Interesting notes above, I had a look at how you do this and what the considerations are - I wrote a couple of notebooks on it:Notes on tree nestingReading highly nested tree data as Polars...

View Article

Answer by Louis Maddox for Polars: How to reorder columns in a specific order?

I wrote a plugin for this (on GitHub here), please try it out:pip install polars-permutePolars Permute PluginA Polars plugin for easily reordering DataFrame columns.Supports column permutations like...

View Article

Comment by Louis Maddox on How to maintain Polars DataFrame metadata through...

This does not persist, with_columns (github.com/pola-rs/polars/blob/…) calls a classmethod (github.com/pola-rs/polars/blob/…) which calls __new__ not __init__

View Article


Comment by Louis Maddox on How can I update Google Colab's Python version?

Not working for Python 3.12, crashes and won't connect on refresh, I had to hard refresh. Appears to have broken something in Colab for this specific notebook! The message says something about not...

View Article


Comment by Louis Maddox on how to install devtoolset-8 / GCC 8 on Amazon Linux 2

The URL is now 404, archived, I changed them to the current ones but the repo no longer works when used as shown

View Article

Comment by Louis Maddox on Pandas read_sql() - AttributeError: 'Engine'...

Known bug in 2.2 github.com/pandas-dev/pandas/issues/57049

View Article

Answer by Louis Maddox for Create a field which is immutable after being set

You now do this (in Pydantic v2) with the Field(frozen=True) kwarg (docs)Immutability ¶The parameter frozen is used to emulate the [frozen dataclass]behaviour. It is used to prevent the field from...

View Article

Answer by Louis Maddox for Parse mailto urls in Python

I like Alexander's answer but it is in Python 2! We now get urlparse() and parse_qs() from urllib.parse. Also note that sorting the header in reverse puts it in the order: to, from, body.from...

View Article


Answer by Louis Maddox for python3 dataclass with **kwargs(asterisk)

All of these changes are well-meaning but pretty clearly against the spirit of dataclasses, which is to avoid writing a bunch of boilerplate to set up a class.Python 3.10 introduces the match statement...

View Article

Answer by Louis Maddox for how to grep ASCII control character

As suggested here, awk portably finds control charactersawk '/\01/'

View Article


Answer by Louis Maddox for Convert text to bytes from Bash shell?

I adapted Machinexa's nice answer a little for my needsencoding="utf-8" is the default so no need to passmore concise to just import sys and use directlyHere I'm looking to make a unique set not a list...

View Article

Answer by Louis Maddox for Counting commas in a line in bash

An example Python command you could run (since it's going to be installed on most modern shells) is:python -c "import pathlib; print({l.count(',') for l in...

View Article


Create a new file in git bash

I've got Git for Windows running, I'm not sure if it's supposed to function as a text editor though?I think I installed it with the Vim editor, but in a Git Bash shell how do I create a file, such as...

View Article

Piping Rscript gives error after output

I wrote a small R script to read JSON, which works fine but upon piping withRscript myscript.R | headthe (full, expected) output comes back with an errorError: ignoring SIGPIPE signalExecution...

View Article

How to see logs of Dockerfile build when using custom AWS Lambda container image

AWS Lambda supports container images rather than using the standard Amazon Linux (2) image, but I can't figure out where the logs from the Dockerfile build are stored.I can find and see the logs for...

View Article
Browsing index pages (56 articles)


Latest Images