At #Python Frederick, Chris Malec gave a cool overview talk on Pandas. Want to see how GME looked on the market during the "Gamestonk" week? Chris showed us some interesting financial analysis. https://www.youtube.com/watch?v=uFP-W_9UtfQ
Hey friends on the #Fediverse!
It's been 6 years since our last, beloved PyCon Zimbabwe took place. #pyconzim brought us together. It was a time for connecting, sharing, & learning. Now, after years of silence, it's coming back!
We're a community-driven event, & like before we need your help to make it a success. We're calling on all of you to join us in this endeavor. Whether you can offer your time, resources, or just a share on your networks, every bit counts! #python#django#foss
problem: sometimes i write a program that can be configured with json/yaml/toml/whatever. but i hate dealing with raw dictionaries and validating the data myself (or checking whether ["my"]["deep"]["key"] exists before accessing it). creating my own Config class to do that stuff for me is boring and repetitive.
... and have that be validated, ready to go, with convenience functions and everything. if a type doesn't match, raise an error. (also, some more validators like selections, or 'value matches regex'.)
i know attrs can do something like that, but the attributes are stored on the object instead of in an internal dict, and it's not a perfect match. pydantic has BaseSettings, but pydantic is so thoroughly overengineered that i don't want it.
but when i sit down to think about writing a module to do what i want, i realise i'm just reimplementing attrs, but lighter, without attributes stored on the object, and with certain convenience functions.
ought i just build my module on top of attrs, somehow? does my dream module already exist?
Live music at the Brangwyn Hall tonight - mind blown by Caroline Shaw's "The Observatory"
Sunset & sea smell & birdsong
Beginning to understand #Python well enough to start wrangling some local data to "Dig Where I Stand" (any tips for styling matplotlib to only display years on the x axis? #WholeLottaTicks)
I wrote some words on how to implement a collections.Counter in #python that can be compared to scalar values.
To me, this is pretty cool, as it allows you to filter the counts based on a threshold. For instance, ComparableCounter(...) > 10 would result in a new collection containing only values whose count is above 10.
In #Python you can use sub() from the "re" module to do regex string replacing.
If you want to keep a count of the number of replacements done as well, you can use subn() which returns a tuple of the new (replaced) string and the number of replacements made.
So, how can we get a proper answer? Ten years ago, when I wrote “The Milwaukee Soup App”, I used the Kimono (which is long dead) to scrape the soup of the day. You could also write a fiddly script to scrape the value manually. It turns out that there is another option, though. You could use Scrapegraph-ai. ScrapeGraphAI is a web scraping Python library that uses LLM and direct graph logic to create scraping pipelines for websites, documents, and XML files. Just say which information you want to extract and the library will do it for you.
Let’s take a look at an example. The project has an official demo where you need to provide an OpenAI API key, select a model, provide a link to scrape, and write a prompt.
As you can see, it reliably gives you the flavor of the day (in a nice JSON object). It will go even further, though because if you point it at the monthly calendar, you can ask it for the flavor of the day and soup of the day for the remainder of the month and it can do that as well.
I am running Python 3.12 on my Mac but when you run pip install scrapegraphai to install the dependencies, it throws an error. The project lists the prerequisite of Python 3.8+, so I downloaded 3.9 and installed the library into a new virtual environment.
Let’s see what the code looks like.
You will notice that just like in yesterday’s How to build a RAG system post, we are using both a main model and an embedding model.
At this point, if you want to harvest flavors of the day for each location, you can do so pretty simply. You just need to loop through each of Culver’s location websites.
Have a question, comment, etc? Please feel free to drop a comment, below.
Hmm I've only ever built sites using #Django, bcos I'm most good at #Python and I'm just super familiar with all the features (and quirks) of Django and it's been great, but honestly being good at only Django (when it comes to web dev) does gimme huge impostor syndrome cos I know fuck all when people talk about #Node and whatnot :(
Maybe I can learn how to build a site using #Eleventy so I too can speak gibberish lingo I never understood before with other fellow programmers?
pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.