mblayman, to python
@mblayman@mastodon.social avatar

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

bbelderbos, to python
@bbelderbos@fosstodon.org avatar

Streamline your test data generation in #Python with Faker 💡 🎉

Here's a quick snippet to create realistic user profiles with matching names and emails.

Enhance your testing with data that feels real. 🐍🔧📈

ffissore, to python
@ffissore@hachyderm.io avatar

I won’t be able to go to @pycon. If you need tickets, I’m happy to sell you mine #python #pycon

hamub, to fediverse
@hamub@fosstodon.org avatar

Hey friends on the !
It's been 6 years since our last, beloved PyCon Zimbabwe took place. 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!

hynek, to python
@hynek@mastodon.social avatar

Come for wisdom on tox & Nox – stay for unrelated gems that will improve your life!

https://youtu.be/ImBvrDvK-1U https://mastodon.social/@treyhunner/112419178337248517

carmenbianca, to python
@carmenbianca@todon.eu avatar

i want to create a module but i need a 🦆

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.

what i want to do is this:

class MyConfig:
foo: str
bar: int

my_config = MyConfig.from_dict({"foo": "hello", " bar": 1})

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

webology, to random
@webology@mastodon.social avatar

🐍 TIL build-and-inspect-python-package GitHub Action workflow plus some bonus Nox + Tox: https://micro.webology.dev/2024/05/10/til-buildandinspectpythonpackage-github.html

villares, to python Portuguese
@villares@pynews.com.br avatar
vic, to python
@vic@howcyborgs.chat avatar

  1. Live music at the Brangwyn Hall tonight - mind blown by Caroline Shaw's "The Observatory"
  2. Sunset & sea smell & birdsong
  3. Beginning to understand 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? )

@3goodthings

treyhunner, to python
@treyhunner@mastodon.social avatar

Python's "next" function is designed to be used with iterators.

Read more 👉 https://trey.io/UFI8MG

#Python

rasterweb, to RSS
@rasterweb@mastodon.social avatar

What are some good (simple!) options for automagically posting RSS stuff on the Fediverse?

This works with Mastodon well enough, but I'd love a list of alternatives.

➡️ https://github.com/aserper/masto-rss

baumanno, to python

I wrote some words on how to implement a collections.Counter in 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.

Any feedback is gladly received! 😀

https://baumanno.de/2024/05/a-comparable-counter-for-python/

hynek, to python
@hynek@mastodon.social avatar

In my quest to produce a shorter video, I’ve produced my longest so far:

tox vs Nox: What are they for & How do you choose?: https://www.youtube.com/watch?v=ImBvrDvK-1U

In which I introduce those two indispensable tools and reflect my own usage of BOTH. Enjoy!

leonid, to python German
@leonid@norden.social avatar

Gibt es gute Hostingdienste, um eine Django/Python-App ähnlich einfach wie PHP zu hosten?

djangobrew, to django
@djangobrew@fosstodon.org avatar

New Django Brew episode alert! 🎧 https://djangobrew.com

In Episode 2, Sudsy Forms and Spicy Takes 🔥, we discuss Django Forms and our experiences with them, helpful third-party libraries, and more!

We also have some hot takes, try to pronounce the longest place name on Earth, and chat about the best post-apocalyptic coffee. 🫣

Subscribe in your podcast app and listen now! If you ❤️ Django Brew, we’d appreciate 5 ⭐️ and a review wherever you get your podcasts!

dongheena, to python
@dongheena@fosstodon.org avatar
bbelderbos, to python
@bbelderbos@fosstodon.org avatar

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

For example:

joe, to ai

A few weeks back, I thought about getting an AI model to return the “Flavor of the Day” for a Culver’s location. If you ask Llama 3:70b “The website https://www.culvers.com/restaurants/glendale-wi-bayside-dr lists “today’s flavor of the day”. What is today’s flavor of the day?”, it doesn’t give a helpful answer.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-12.29.28%E2%80%AFPM.png?resize=1024%2C690&ssl=1

If you ask ChatGPT 4 the same question, it gives an even less useful answer.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-12.33.42%E2%80%AFPM.png?resize=1024%2C782&ssl=1

If you check the website, today’s flavor of the day is Chocolate Caramel Twist.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-12.41.21%E2%80%AFPM.png?resize=1024%2C657&ssl=1

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.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-12.35.29%E2%80%AFPM.png?resize=1024%2C660&ssl=1

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.

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-1.14.43%E2%80%AFPM.png?resize=1024%2C851&ssl=1

Running it locally with Llama 3 and Nomic

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.

So, what does the output look like?

https://i0.wp.com/jws.news/wp-content/uploads/2024/05/Screenshot-2024-05-09-at-2.28.10%E2%80%AFPM.png?resize=1024%2C800&ssl=1

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.

https://jws.news/2024/how-to-use-ai-to-make-web-scraping-easier/

#AI #ChatGPT #llama3 #LLM #Ollama #Python #ScrapegraphAi #WebScraping

fallenhitokiri, to python
@fallenhitokiri@social.screamingatmyscreen.com avatar

“Members of any membership class with voting rights must affirm each year…“

A drama in three acts

  • register: (captcha) I think I should have an account already?!
  • login: (captcha) obviously not, I could register the mail address
  • no idea, same page as before without login button
  • click link in email: „obviously“ not a member

I have no idea what’s going on.
I’m not sure I have the energy to care.
I might simply reassign the money to another org.

Login
Don’t know what to do
Not a member?

adamchainz, to python
@adamchainz@fosstodon.org avatar

✍️ New post covering a small helper to return all subclasses of a given class.

https://adamj.eu/tech/2024/05/10/python-all-subclasses/

henryiii, to python
@henryiii@fosstodon.org avatar

Python 3.13 beta 1 is out, which means it's time for my yearly post on what's new: https://iscinumpy.dev/post/python-313/

irfan, to django

Hmm I've only ever built sites using , bcos I'm most good at 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 and whatnot :(

Maybe I can learn how to build a site using so I too can speak gibberish lingo I never understood before with other fellow programmers?

RE: https://social.lol/users/bw/statuses/112414344202116592

henryiii, to python
@henryiii@fosstodon.org avatar

This feature of uv is not talked about enough:

uv pip install --exclude-newer 2020-01-01 -r requirements.txt

I was able to recover and build a project untouched for many years using this easily!

brianb, to python
@brianb@fosstodon.org avatar

Is there a better interface for interacting with the breakpoint() debugger in a script rather than use c/n to go line by line?

textovervideo, to python
@textovervideo@fosstodon.org avatar

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.

https://pyinfra.com/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Leos
  • cubers
  • magazineikmin
  • everett
  • thenastyranch
  • Youngstown
  • slotface
  • hgfsjryuu7
  • ngwrru68w68
  • rosin
  • kavyap
  • khanakhh
  • PowerRangers
  • DreamBathrooms
  • anitta
  • mdbf
  • InstantRegret
  • ethstaker
  • Durango
  • osvaldo12
  • tacticalgear
  • vwfavf
  • tester
  • GTA5RPClips
  • cisconetworking
  • modclub
  • normalnudes
  • provamag3
  • All magazines