duckdb can just query any pandas dataframe that is in memory.
I tried running it against a list of objects and got this error. Great error message that gives me supported types right in the message.
All posts with the tag "python"
duckdb can just query any pandas dataframe that is in memory.
I tried running it against a list of objects and got this error. Great error message that gives me supported types right in the message.
pytest-subtests is a package to register multiple subtests within a similar test function.
![[None]]
When setting up a new machine, vm, docker image you might be installing command line tools from places like pip. They will often put executables in your ~/.local/bin directory, but by default your shell is not looking in that directory for commands.
WARNING: The script dotenv is installed in '/home/falcon/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
To solve this you need to add that directory to your $PATH.
export PATH=$PATH:~/.local/bin
To make this change permanant add this line to your shell’s init script, which is likely something like ~/.bashrc or ~/.zshrc.
Very inspiring textual project to check out how they set up the ui. Their intro video has a pretty epic dev experience.
wsrepl is an epic websocket repl built in python on the textual framework.
When fetching pydantic models from the database with sqlmodel, and you cannot select your item by id, you probably need to use a where clause. This is the sqlmodel way of doing it.
Here is a snippet of how I am using sqlmodel select and where to find a post by link in my thoughts database.
In order to turn url encoded links back into links that I would find in the database of my thoughts project I need to urldecode them when they hit the api. When anything hits the api it must urlencode the links in order for them to be sent correctly as data and not get parsed as part of the url.
Here is a snippet of how I am using urlib.parse.unquote to un-encode encoded urls so that I can fetch posts from the database.
Prime reviews an article with some hot takes about python being slow and quirky, but good enough for a lot of things. Especially data applications that have libraries written in C.
The next version of markata will be around a full second faster at building it’s docs, that’s a 30% bump in performance at the current state. This performance will come when virtual environments are stored in the same directory as the source code.
I was looking through my profiler for some unexpected performance hits, and noticed that the docs plugin was taking nearly a full second (sometimes more), just to run glob.
| |- 1.068 glob markata/plugins/docs.py:40 | | |- 0.838 <listcomp> markata/plugins/docs.py:82 | | | `- 0.817 PathSpec.match_file pathspec/pathspec.py:165 | | | [14 frames hidden] pathspec, <built-in>, <string>
I started looking for different solutions and what I found was that I was hitting pathspec with way more files than I needed to.
len(list(Path().glob("**/*.py"))) # 6444 len([Path(f) for f in glob.glob("**/*.py", recursive=True)]) # 110
After digging into the docs I found that...
...
I don’t want to be an expert python developer.
https://www.youtube.com/watch?v=iKzOBWOHGFE
# Version 1 def newton(f, x0, fprime, maxiter=100): ... # Version 2 def newton(f, x0, fprime, tol=1e-6, maxiter=100): ... # 🔴 Broke in Version 2 newton(f, x0, fprime, 100)
In an alternate timeline the maintainer of newton could have chose to use keyword only arguments to prevent pain for users of libraries, or poor api design due to fear of changing api on users.
global Field global BaseModel from pydantic import BaseModel from pydantic import Field
Pydantic is a Python library for serializing data into models that can be validated with a deep set of built in valitators or your own custom validators, and deserialize back to JSON or dictionary.
To install pydantic you will first need python and pip. Once you have pip installed you can install pydantic with pip.
pip install pydantic
Always install in a virtual environment
To get started with pydantic you will first need to create a Pydantic model. This is a python class that inherits from
pydantic.BaseModel....
The following is a playthrough of Star Wars Text Adventure with a 10 yr old.The following is a playthrough of StarThe following is a playthrough of Star
I was reading about pydantic-singledispatch from Giddeon’s blog and found it very intersting. I’m getting ready to implement pydantic on my static site generator markata, and I think there are so uses for this idea, so I want to try it out.
Let’s set up some pydantic settings. We will need separate Models for each environment that we want to support for this to work. The whole idea is to use functools.singledispatch and type hints to provide unique execution for each environment. We might want something like a path_prefix in prod for environments like GithubPages that deploy to /<name-of-repo> while keeping the root at / in dev.
...
I really like having global cli command installed with pipx. Since textual 0.2.x (the css release) is out I want to be able to pop into textual devtools easily from anywhere.
You can pipx install textual.
pipx install textual
But if you try to run any textual cli commands you will run into a ModuleNotFoundError, because you need to install the optional dev dependencies.
Traceback (most recent call last): File "/home/u_walkews/.local/bin/textual", line 5, in <module> from textual.cli.cli import run File "/home/u_walkews/.local/pipx/venvs/textual/lib/python3.10/site-packages/textual/cli/cli.py", line 4, in <module> import click ModuleNotFoundError: No module named 'click'
In order to install optional dependencies with pipx you need to first install the library, then inject in the optional dependencies using the square bracket syntax.
I am working through the textual tutorial, and I want to put it in a proper cli that I can pip install and run the command without textual run --dev app.py. This is a fine pattern, but I also want this to work when I don’t have a file to run.
I set up a new project running hatch new, and added the following entrypoint, giving me a tutorial cli command to run.
... [project.scripts] tutorial = 'textual_tutorial.tui:tui'
https://waylonwalker.com/hatch-new-cli/
If you are using setup.py, you can set up entrypoints in the setup command.
...
Markata now allows you to create jinja extensions that will be loaded right in with nothing more than a pip install.
The entry for 0.5.0.dev2 from markata’s changelog
In my adventure to learn django, I want to be able to setup REST api’s to feed into dynamic front end sites. Potentially sites running react under the hood. To get started lets open up a Now we need to declare Next I will create all the files that I need to get the api running. ...
todo app that I created with django-admin startproject todo.pip install djangorestframework Install APP #
rest_framwork as an INSTALLED_APP.INSTALLED_APPS = [ ... "rest_framework", ... ] create the api app #