Feeds
Real Python: The Real Python Podcast – Episode #230: marimo: Reactive Notebooks and Deployable Web Apps in Python
What are common issues with using notebooks for Python development? How do you know the current state, share reproducible results, or create interactive applications? This week on the show, we speak with Akshay Agrawal about the open-source reactive marimo notebook for Python.
[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
Web Review, Week 2024-48
Let’s go for my web review for the week 2024-48.
Are Overemployed ‘Ghost Engineers’ Making Six Figures to Do Nothing?Tags: tech, algorithm, productivity, business
Can you see this kind of models getting abused quickly? Clearly it says something about the tech industry wanting to reduce costs.
https://www.404media.co/are-overemployed-ghost-engineers-making-six-figures-to-do-nothing/
Tags: tech, politics
Technology isn’t neutral. It’s impossible to ignore the ideologies of the moguls funding or leading big tech companies. We can’t afford to trust their promises.
https://blog.avas.space/tech-utopia-fantasy/
Tags: tech, social-media, twitter, law
Everything is in the title… if you thought you owned anything on those platforms, think twice.
Tags: tech, ai, machine-learning, gpt, law, copyright
More shady practices to try to save themselves. Let’s hope it won’t work.
Tags: tech, ai, machine-learning, gpt, ecology, water
The water problem is obviously hard to ignore. This piece does a good job illustrating how large the impact is.
Tags: tech, self-hosting, privacy, gdpr, law, politics, decentralized
Definitely this. Sure we should seek for decentralization, but this is not going to happen or be effective without regulation. Ensuring privacy is a legislative and political problem as much as a technical one.
https://matduggan.com/self-hosting-isnt-a-solution-its-a-patch/
Tags: tech, social-media, fediverse, decentralized, bluesky
A long and comprehensive analysis of Bluesky. Also brings interesting critiques about both Bluesky and the Fediverse. Clearly Bluesky as of today is not effectively decentralized and shouldn’t be considered as such.
https://dustycloud.org/blog/how-decentralized-is-bluesky/
Tags: tech, social-media, bluesky, fediverse, decentralized
The debate about how BlueSky and decentralisation or federation continues. It’s nice to see how civilized the people involved are. This is how we can make progress.
https://whtwnd.com/bnewbold.net/3lbvbtqrg5t2t
Tags: tech, kde, documentation
Since the documentation is severely lacking in this area, this ends up being a nice how to. I wish we’d have more like this in the official documentation.
https://datagirl.xyz/posts/kontact_plugin_writing.html
Tags: tech, c++, safety, community
It’s clear that a split is forming in the C++ community on how to evolve the language. Could it lead to a full fledged divorce?
https://herecomesthemoon.net/2024/11/two-factions-of-cpp/#fnref:4
Tags: tech, c++, metaprogramming, type-systems
Are you confused with the use of requires in C++20? This post might help.
https://www.think-cell.com/en/career/devblog/if-constexpr-requires-requires-requires
Tags: tech, rust, safety
Good explanation of what Rust’s unsafe really does.
https://oida.dev/unsafe-for-work/
Tags: tech, java, memory, garbage-collector
Looks like there is a new venue to improve garbage collectors performance. This should be interesting down the line.
https://inside.java/2024/11/22/mark-scavenge-gc/
Tags: tech, xslt
Tempted to do some XSLT? Did you notice it’s almost 2025? So yeah, just don’t. At least there’s a proper alternative if you still need to process that XML input.
https://github.com/Juniper/libslax/wiki
Tags: tech, security, dns
Interesting approach to have secure and decentralized naming while keeping it human readable.
https://files.spritely.institute/papers/petnames.html
Tags: tech, programming, design, craftsmanship
This is a good point. Idiosyncrasies are not necessarily a bad thing for naming things. Natural languages are fickle friends, you might need to rely to specific metaphors in order to disambiguate.
https://wiki.dpk.land/Naming_things
Tags: tech, programming, complexity, design, tests
Another rebuttal of Clean Code. Most of it makes sense if not overdone. There’s the usual confusion around the “unit tests” term though, so take that section with a pinch of salt.
https://htmx.org/essays/codin-dirty/
Bye for now!
Kushal Das: Amnesty seminar on activism
2 Weeks ago I was down with fever, but as I became better after a few days I managed to attend Amnesty International's Stockholm chapter's event on activism. I had to travel to a different part of Stockholm, which was fun.
The day started with welcome talk and then a new "Palestine Activist Group" presented their work (in both English and Swedish). Then the main opening talk (in Swedish) from a very senior Swedish journalist about history and important dates related to Palestine. I managed to understand 50-60% of the words. Still a lot of learn.
During the break I had longer chats about privacy, data and our lives. It was good to find folks who knows/uses Python/Fedora/Debian/Ubuntu and other Open Source tools in their daily lives, sometimes even without knowing.
After the morning break, I attended a workshop about being an activist. It was filled with discussions, and of course a lot of new words in Swedish for me. But, the delivery of the workshop was good, people talked about what they think about being an individual activist and things to consider etc.
Next day I had a workshop for a selected group, about boycotting large services and how to providing least amount data to preserve our privacy. The group consisted people from various parts of Swedish society, people working in other government agencies and large multinational companies.
We talked about metadata and phones provide both metadata and real data to the various services via apps. Explaining people to imagine that every time they get out of home, there are many humans walking with them to every destination, keeping notes of every place visit, and every chats they are having with another person or about groups, and then later selling that information to other businesses. It is one thing to talk about these, but it is complete opposite to show. So, I showed them live how much our phones/computers talk. I had my old Pixel4a configured with GrapheneOS, and one of the participant connected their regular Pixel phone to the same VPN. And people seemed to be offended by seeing the amount of data flowing, even when the phone is not use. The below is a screenshot I took today morning from the same demo setup.
We also talked about various chatting platforms, I already built another system to teach kids about how various social chatting platforms work. It was a perfect tool for this demo. We discussed about various other technologies in our daily lives and how they affect privacy.
Python GUIs: Building a Translation Application Using Tkinter — Translate Your Text With Python and Tkinter
Whether learning a new natural language or just browsing foreign websites, you sometimes come across text that you want to read but is written in a language you don't fully understand. To translate one natural language into your native language you can use a translator tool, like Google Translate.
In this tutorial, we'll build a desktop translator application to translate natural language using the Google Translate APIs. The UI will be built using the Tkinter GUI library from the Python standard library.
Table of Contents- Demo: A Translator App with Tkinter
- Installing the Required Packages
- Building the Window
- Creating the GUI
- Implementing the Translation Functionality
- Using the Translator App
- Conclusion
We'll work through the process of building the app step by step. Once we finish the tutorial, the app will look and work like the following:
You can select the source and destination languages. Then, you can paste or type some text in the left-hand area and hit the Translate button to get the translated text in the right-hand area.
Installing the Required PackagesOur Translator uses the googletrans library to perform the actual translation via Google. Tkinter is already available in the standard library, so we just need to install googletrans-py and a library called httpcore to deal with connection errors.
The first task will be to set up a Python virtual environment. Open the terminal, and run the following commands:
- Windows
- macOS/Linux
Working through these instructions, first we create a root directory for the Translator app. Next we create and activate a Python virtual environment for the project. Finally, we install googletrans and httpcore packages.
Now, create a file named translator.py in the root of your project. Additionally, create a folder called images/ where you'll store the icons for the application. The folder structure should look like this:
python translator/ &boxv &boxvr&boxh&boxh images/ &boxv &boxvr&boxh&boxh arrow.png &boxv &boxur&boxh&boxh logo.png &boxv &boxur&boxh&boxh translator.pyThe images for this project can be downloaded here.
The images/ folder contains the two icons that you'll use for the application. The translator.py is the app's source file.
Building the WindowOpen the translator.py file with your favorite Python code editor. We'll start by creating our main window:
python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) if __name__ == "__main__": app = TranslatorApp() app.mainloop()This code imports Tkinter and then defines the application's main class, which we have called TranslatorApp. This class will hold the application's main window and allow us to run the main loop.
Importing tkinter under the alias tk is a common convention in Tkinter code.
Inside the class we define the __init__() method, which handles initialization of the class. In this method we first call the initializer __init__() of the parent class, tk.Tk, to initialize the app's window. Then, we set the window's title using the title() method. To make the window unresizable, we use the resizable() method with width and height set to False.
At the bottom of the code, we have the if __name__ == "__main__" idiom to check whether the file is being run directly as an executable program. Inside the condition block we first create an instance of TranslatorApp and then run the application's main loop or event loop.
If you run this code, you'll get an empty Tkinter window on your desktop:
python python translator.pyThe empty Tkinter window
Creating the GUINow that the main window is set up, let's start adding widgets to build the GUI. To do this, we'll create a method called setup_ui(), as shown below:
python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) if __name__ == "__main__": app = TranslatorApp() app.mainloop()The setup_ui() method will define the application's GUI. In this method, we first create a frame widget using the tk.Frame class whose master argument is set to self (the application's main window). Next, we position the frame inside the main window using the pack() geometry manager, using padx and pady arguments to set some padding around the frame.
Finally, we add the call to self.setup_ui() to the __init__() method.
We'll continue to develop the UI by adding code to the setup_ui() method.
Net we'll add the app's logo. In the setup_ui() method add the following code below the frame definition:
python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") if __name__ == "__main__": app = TranslatorApp() app.mainloop()This code loads the logo using the tk.PhotoImage class. To resize it, we use the subsample() method. Then, we add the logo to the frame using a tk.Label widget. The label takes the frame and the logo as arguments. Finally, to position the logo, we use the grid() geometry manager with appropriate values for the row, column, and sticky arguments.
The sticky argument determines which side of a cell the widget should align -- North (top), South (bottom), East (right) or West (left). Here we're aligning it on the Wiest or left of the cell with "w":
Tkinter window with the Google Translate logo in it
Let's start adding some inputs to the UIs. First, we'll create the language selection drop-down boxes:
python import tkinter as tk import tkinter.ttk as ttk from googletrans import LANGUAGES DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox languages = [lang.title() for lang in LANGUAGES.values()] self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") if __name__ == "__main__": app = TranslatorApp() app.mainloop()We can get a list of languages from the googletrans module. We also define the default languages for when the application starts up, using constants DEFAULT_SOURCE and DEFAULT_DEST.
To build the language list for the combo boxes we take the LANGUAGES dictionary imported from googletrans and convert it into a list of strings called languages. We use a list comprehension to make all the names start with an uppercase letter, using title().
Next we create two combo boxes, to hold the list of source and destination langauges. The combo boxes are created using the ttk.Combobox class. One to the left and another to the right. Between the combo boxes, we've also added an arrow icon loaded using the tk.PhotoImage class. Again, we've added the icon to the app's window using ttk.Label.
Both combo boxes take frame and values as arguments. The values argument populates the combo boxes with languages. To specify the default language, we use the current() method, looking up the position of our default languages in the languages list with index().
To position the combo boxes inside the frame, we use the grid() geometry manager with the appropriate arguments. Run the application, and you will see the following window:
Source and destination languages
If you click on the sources combo box on the left, then you get the following:
Source language combo box
Similarly, if you click on the destination combo box on the right, you get the following:
Destination combo box
With the source and destination combo boxes in place, let's add three more widgets: two scrollable text widgets and a button. The scrollable text on the left will hold the source text, while the scrollable text on the right will hold the translated text. The button will allow us to run the actual translation.
Get back to the code editor and update the setup_ui() method as follows. Note that we also need to import the ScrollText class:
python import tkinter as tk import tkinter.ttk as ttk from tkinter.scrolledtext import ScrolledText from googletrans import LANGUAGES DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox languages = [lang.title() for lang in LANGUAGES.values()] self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") # Source text self.from_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, ) self.from_text.grid(row=2, column=0) # Translated text self.to_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, state="disabled", ) self.to_text.grid(row=2, column=2) # Translate button self.translate_button = ttk.Button( frame, text="Translate", command=self.translate, ) self.translate_button.grid(row=3, column=0, columnspan=3, pady=10) def translate(self): pass if __name__ == "__main__": app = TranslatorApp() app.mainloop()In the code snippet, we use the ScrolledText class to create the two scrolled text areas. Both text areas take frame, font, width, and height as arguments. The second text area also takes state as an additional argument. Setting state to "disabled" allows us to create a read-only text area.
Then, we use the ttk.Button class to create a button with frame, text, and command as arguments. The command argument allows us to bind the button's click event to the self.translate() method, which we will define in a moment. For now, we've added a placeholder.
To position all these widgets on the app's window, we use the grid() geometry manager. Now, the app will look like the following:
Translator app's GUI
Our translation app's GUI is ready! Finally, we can start adding functionality to the application.
Implementing the Translation FunctionalityWe'll implement the language translation functionality in the translate() method. This gets the current values from the UI and then uses googletrans to perform the translation. We need a few more imports, and to create the translator instance at the top of the application:
python import tkinter as tk import tkinter.ttk as ttk from tkinter.messagebox import showerror from tkinter.scrolledtext import ScrolledText import httpcore from googletrans import LANGUAGES, Translator DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" translator = Translator()Here we've imported the showerror helper for displaying error boxes in our application. We've imported httpcore which we'll use to handle HTTP errors when accessing the API. Finally, we've added an import for the Translator class from googletrans. This is what handles the actual translation.
To use it, we create an instance of the class as translator.
We'll continue by implementing the translate method. Below we're just showing the function itself:
python class TranslatorApp(tk.Tk): # ... def translate(self): source_language = self.from_language.get() destination_language = self.to_language.get() text = self.from_text.get(1.0, tk.END).strip() if not source_language or not destination_language: showerror( title="Error", message="Make sure to set the source and destination language", ) return if not text: showerror( title="Error", message="Make sure to enter some text to translate", ) return try: translation = self.translator.translate( text, src=source_language, dest=destination_language, ) except httpcore.ConnectError: showerror( title="Error", message="Make sure you have an internet connection", ) return except Exception as e: showerror( title="Error", message=f"An unexpected error occurred: {e}", ) return self.to_text.config(state="normal") self.to_text.delete(1.0, tk.END) self.to_text.insert(tk.END, translation.text) self.to_text.config(state="disabled")The translate() method handles the entire translation process. It starts by retrieving the source and destination languages from the corresponding combo boxes. If either language is not defined, then we display a message to inform the user about the problem. To do this, we use a showerror dialog.
Next, we try to get the input text from the source scrolled area on the left. If the user doesn't provide any text, then we display an error with the appropriate message.
Once we have the source and destination language and some text to translate, we can perform the actual translation. To run this task, we use the translate() method of the self.translator object, which is an instance of googletrans.Translator.
If the call to translate() finds a connection error, then we tell the user to check their internet connection. To handle any other exceptions, we catch the generic Exception class and display an error message with the exception details.
If the translation is successful, then we enable the destination scrolled area, display the translated text, and disable the area again so it remains read-only.
The complete final code is shown below:
python import tkinter as tk import tkinter.ttk as ttk from tkinter.messagebox import showerror from tkinter.scrolledtext import ScrolledText import httpcore from googletrans import LANGUAGES, Translator DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" translator = Translator() class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): languages = [lang.title() for lang in LANGUAGES.values()] frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") # Source text self.from_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, ) self.from_text.grid(row=2, column=0) # Translated text self.to_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, state="disabled", ) self.to_text.grid(row=2, column=2) # Translate button self.translate_button = ttk.Button( frame, text="Translate", command=self.translate, ) self.translate_button.grid(row=3, column=0, columnspan=3, pady=10) def translate(self): source_language = self.from_language.get() destination_language = self.to_language.get() if not source_language or not destination_language: showerror( title="Error", message="Make sure to set the source and destination language", ) return text = self.from_text.get(1.0, tk.END).strip() if not text: showerror( title="Error", message="Make sure to enter some text to translate", ) return try: translation = translator.translate( text, src=source_language, dest=destination_language, ) except httpcore.ConnectError: showerror( title="Error", message="Make sure you have an internet connection", ) return except Exception as e: showerror( title="Error", message=f"An unexpected error occurred: {e}", ) return self.to_text.config(state="normal") self.to_text.delete(1.0, tk.END) self.to_text.insert(tk.END, translation.text) self.to_text.config(state="disabled") if __name__ == "__main__": app = TranslatorApp() app.mainloop() Using the Translator AppThe video below demonstrates how we can use our app to translate some text from one natural language to another:
Great! You have successfully built a language translator using Python, Tkinter, and the googletrans package.
ConclusionIn this tutorial we built a Translator application using the Tkinter GUI library from the Python standard library. We worked step by step through building the UI using a grid layout, and then implemented the language translation functionality with googletrans.
Try and take what you've learnt in this tutorial & applying it to your own projects!
Release GCompris 4.3
Today we are releasing GCompris version 4.3.
It contains bug fixes and graphics improvements on multiple activities.
It is fully translated in the following languages:
- Arabic
- Bulgarian
- Breton
- Catalan
- Catalan (Valencian)
- Greek
- UK English
- Esperanto
- Spanish
- Basque
- French
- Galician
- Croatian
- Hungarian
- Indonesian
- Italian
- Lithuanian
- Latvian
- Malayalam
- Dutch
- Norwegian Nynorsk
- Polish
- Brazilian Portuguese
- Romanian
- Russian
- Slovenian
- Albanian
- Swedish
- Swahili
- Turkish
- Ukrainian
It is also partially translated in the following languages:
- Azerbaijani (97%)
- Belarusian (87%)
- Czech (97%)
- German (96%)
- Estonian (96%)
- Finnish (95%)
- Hebrew (96%)
- Macedonian (90%)
- Portuguese (96%)
- Slovak (84%)
- Chinese Traditional (96%)
You can find packages of this new version for GNU/Linux, Windows, Android, Raspberry Pi and macOS on the download page. Also this update will soon be available in the Android Play store, the F-Droid repository and the Windows store.
Thank you all,
Timothée & Johnny
remotecontrol @ Savannah: Smart gadgets’ failure to commit to software support could be illegal, FTC warns
PyCharm: Simplify ML Workflows With Hugging Face and PyCharm
Ready to boost your workflows with pre-trained ML models?
PyCharm‘s integration with Hugging Face is designed to bring a new level of productivity to your machine learning and development workflows.
This integration helps you seamlessly find and use the best-fit model from the Hugging Face library, access model documentation, and manage models – all in your IDE.
The integration is available starting with PyCharm 2024.2.
Read the blog post to learn more about the integration and how to use it.
What is Hugging Face?Hugging Face is a platform where machine learning and data science developers share pre-trained AI models. The platform provides tools to build, deploy, and train machine learning models.
Key features of the Hugging Face integrationPyCharm’s integration with Hugging Face is designed to streamline workflows for developers, enabling seamless access to pre-trained machine learning models from the IDE. This integration allows you to:
- Simplify model selection and usage.
- Import models as easily as importing any other library, allowing you to stay focused on your code.
- Eliminate distractions caused by switching between tools and browsers.
- Maintain control over your machine storage.
Lysandre Debut, the Chief Open-Source Officer at Hugging Face, shares:
“As a Hugging Face user, even more so than as a Hugging Face team member, the HF integration in PyCharm has been instrumental in speeding up the machine learning workflows I’ve worked on. As a result of this feature, I find myself keeping my focus in the IDE, with much less context switching during development.” Easily find the best model for your task
Looking to use a Hugging Face model but unsure which one fits your needs? Whether you’re building a text classifier, working on image recognition, or exploring other areas, PyCharm simplifies the process for you.
With the Hugging Face integration, you can quickly access a vast library of models tailored to various tasks. Right-click in the editor, select Insert HF Model, and explore models categorized by task type. To make your search even easier, you can filter models by likes, licensing, or specific tags.
For each model, PyCharm provides a detailed model card, including essential information and sample code that you can use. Found the perfect fit? Just click Use Model to insert the necessary code snippet directly into your project and start building immediately.
Seamlessly access model documentationWhen working with machine learning models, quick access to documentation is handy – and PyCharm ensures you stay focused. With the Hugging Face integration, you can instantly view detailed model information without leaving your IDE or interrupting your workflow.
Simply hover over a model name in your code, and PyCharm will display its full model card, including the tasks the model is designed for, date of its last update, its origin, licensing details, and other details.
No more jumping between your browser and IDE – everything you need is right next to your code.
Manage models stored on your machineHugging Face models can take up significant storage space, but PyCharm makes it easy to stay in control. With this integration, you can view the models you’ve downloaded, identify those you no longer need, and declutter with ease.
Just head to the Hugging Face tool window to see and manage your models.
PyCharm helps you to keep your system optimized while ensuring you retain access to the tools you actually need – all from the comfort of your IDE!
Get started with PyCharm integrated with Hugging FacePyCharm is a powerful IDE designed for machine learning, data science, and web development. It has everything you need for productive coding, including intelligent coding assistance (both local and AI-powered), smart navigation, and project-wide refactorings.
It also provides a full suite of integrations tailored to streamline machine learning and data science workflows, including support for Jupyter Notebooks, Databricks, and popular scientific libraries like pandas, Polars, NumPy, scikit-learn, and more.
Use the PyCharm4HF code on the redeem page below to get started with PyCharm for free.
Get a 3-month PyCharm subscription for freeNeed more guidance? Head to the documentation for step-by-step instructions on using Hugging Face with PyCharm.
We’d love to hear your thoughts! Share your experience with the integration in the comments below.
joshics.in: Unleashing Flexibility: How Headless Drupal is Shaping the Future of Content Delivery
Headless Drupal is changing the course for content management systems by offering a fresh approach to how digital content is delivered across platforms.
At its core, headless Drupal separates the backend (where content is stored and managed) from the frontend (where content is displayed). This decoupling allows for a greater range of flexibility and customization in how content is presented to users, leading to faster, more dynamic websites that can easily integrate with a multitude of modern tech stacks.
Why choose headless?The benefits are abundant. By going headless, organizations can seamlessly deploy content across diverse platforms—from mobile apps and kiosks to IoT devices. This means a blog post, product description, or interactive experience can be shared consistently, regardless of where or how it is consumed.
However, embracing headless architecture is not without its challenges. Managing separate systems can introduce complexity. Multiple moving parts can sometimes lead to increased difficulty in synchronizing the backend with various frontends. Fortunately, Drupal's API-first architecture mitigates these challenges by providing a strong foundation for developers to build upon, ensuring a cohesive integration between systems.
The real excitement comes with the capability to pair Drupal's robust backend with cutting-edge front-end technologies like React, Vue.js, or Angular. This combination results in richer, more engaging user experiences that cater to modern audiences' expectations for speed and interactivity. Developers have the freedom to innovate and tailor the user interface to meet the unique needs of their audience, unencumbered by traditional constraints.
Moreover, businesses are positioned to benefit tremendously from headless Drupal. They gain the ability to bring new features to market rapidly, allowing them to stay ahead in today’s fast-paced digital landscape. Scalability becomes less of a concern, as the architecture easily accommodates growth and a wide variety of digital touchpoints.
Headless Drupal doesn't just promise flexibility; it delivers adaptability essential for future-proofing digital strategies. In an era where customer engagement is king, and technology continues to evolve at unprecedented speeds, having a versatile and powerful content management system is indispensable.
The question isn't just whether headless Drupal is the future—it's about understanding how this evolution in content management can redefine your digital strategy to better connect with users across every platform.
Headless Drupal Drupal Planet Add new commentProgramiz: Python List
Bruno Ponne / Coding The Past: How to calculate Z-Scores in Python
If you’ve worked with statistical data, you’ve likely encountered z-scores. A z-score measures how far a data point is from the mean, expressed in terms of standard deviations. It helps identify outliers and compare data distributions, making it a vital tool in data science.
In this guide, we’ll show you how to calculate z-scores in Python using a custom function and built-in libraries like SciPy. You’ll also learn to visualize z-scores for better insights.
A z-score measures how many standard deviations a data point is from the mean. The formula for calculating the z-score of a data point X is:
\[Z_{X} = \frac{X - \overline{X}}{S}\]Where:
- \(Z_{X}\) is the z score of the point \(X\);
- \(X\) is the value for which we want to calculate the Z score;
- \(\overline{X}\) is the mean of the sample;
- \(S\) is the standard deviation of the sample.
A custom function allows you to implement the z-score formula directly. Here’s how to define and use it in Python:
content_copy Copy
def calculate_z(X, X_mean, X_sd): return (X - X_mean) / X_sdThe function takes three arguments:
- a vector X of values for which you want to calculate the z-scores, like a pandas dataframe column, for example;
- the mean of the values in X;
- the standard deviation of the values in X.
Finally, in the return clause, we apply the z-score formula explained above.
To test our function, we will use data from Playfair (1821). He collected data regarding the price of wheat and the typical weekly wage for a “good mechanic” in England from 1565 to 1821. His objective was to show how well-off working men were in the 19th century. This dataset is available in the HistData R package and also on the webpage of Professor Vincent Arel-Bundock, a great source of datasets. It consists of 3 variables: year, price of wheat (in Shillings) and weekly wages (in Shillings).
We will be calculating the z-scores for the weekly wages. First we load the dataset directly from the website, as indicated in the code below.
content_copy Copy
import pandas as pd data = pd.read_csv("https://vincentarelbundock.github.io/Rdatasets/csv/HistData/Wheat.csv") print(data['Wages'].mean()) print(data['Wages'].std()) data["z-score_wages"] = calculate_z(data["Wages"], data["Wages"].mean(), data["Wages"].std())The average weekly wage during the period was 11.58 Shillings, with a standard deviation of 7.34. With this information, we can calculate the Z score for each observation in the dataset. This is done and stored in a new column called “z-score_wages”.
If you check the first row of the data frame, you will find out that in 1565 the z score was around -0.9, that is, the wages were 0.9 standard deviations below the mean of the values for the whole period.
A second option to calculate z-scores in Python is to use the zscore method of the SciPy library as shown below. Ensure you set a policy for handling missing values if your dataset is incomplete.
In the code below, we calculate the z-scores for Wheat prices. If you look at the z-score summary statistics, you will see that the price of wheat varied between -1.13 and 3.65 standard deviations away from the mean in the observed period.
content_copy Copy
from scipy import stats data["z-score_wheat"] = stats.zscore(data["Wheat"], nan_policy="omit") data["z-score_wheat"].describe()Below you can better visualize the basic idea of z scores: to measure how far away a data point is from the mean in terms of standard deviations. This visualization was created in D3, a JavaScript library for interactive data visualization. Click “See average wage” to see the averave wage for the whole period. Then check out how far from the mean each data point is and finally note that the z-score consists of this distance in terms of standard deviation.
1. See Average Wage 2. See Distance to the Mean 3. See Z-Scores ResetThe code below plots the wage z scores over time and shows them as the distance from the point to the mean, as demonstrated in the D3 visualization above. Please consult the lesson ‘Storytelling with Matplotlib - Visualizing historical data’ to learn more about Matplotlib visualizations.
content_copy Copy
# Calculate mean wage mean_wage = data["z-score_wages"].mean() # Create the plot fig, ax = plt.subplots(figsize=(10, 6)) # Scatter plot of wages over years ax.plot(data["Year"], data["z-score_wages"], 'o', color='#FF6885', label="Wage Z-scores", markeredgewidth=0.5) # Add a horizontal line for the mean wage ax.axhline(y=mean_wage, color='gray', linestyle='dashed', label=f"Mean Z-score = {mean_wage:.2f}") # Add gray lines connecting points to the mean for year, wage in zip(data["Year"], data["z-score_wages"]): ax.plot([year, year], [mean_wage, wage], color='gray', linestyle='dotted', linewidth=1) # Customize the plot ax.set_xlabel("Year") ax.set_ylabel("Z-scores") ax.set_title("Z-scores Over Time") ax.legend() # Show the plot plt.show()Have questions or insights? Leave a comment below, and I’ll be happy to help.
Happy coding!
- A z score is a measure of how many standard deviations a data point is away from the mean. It can be easily calculated in Python;
- You can visualize z-scores using traditional python libraries like Matplotlib or Seaborn.
ImageX: Latest & Greatest Tips to Enhance Your Higher Ed Website’s Online Presence
Is your website the driving engine of your higher ed institution and a powerful catalyst for its goals? Is it effectively attracting prospective students, inspiring alumni, and building a vibrant community? There are always new strategies to boost your website's impact and ensure the answer is a resounding "yes"! As a team that specializes in higher education website design & development, we are passionate about sharing useful tips that can help those in this sector.
MidCamp - Midwest Drupal Camp: Craft Your Perfect Proposal: MidCamp 2025 Session Proposal Workshop
🚀 Ready to take your session ideas to the next level? Whether you're a seasoned speaker or a first-time presenter, the MidCamp 2025 Session Proposal Workshop is here to help you craft standout submissions.
📅 Date: December 12, 2024
🕒 Time: 3:00 PM - 4:00 PM CST
🌐 Location: Virtual via MidCamp Slack (#speakers channel)
This workshop will be led by Aaron Feledy, a seasoned Drupal contributor and experienced speaker. Aaron brings years of expertise in proposal crafting and conference speaking, offering practical advice to help you refine and elevate your session submissions.
Why Attend?Submitting a session proposal can be daunting—but it doesn't have to be! This workshop is designed to guide you through the process, from brainstorming topics to refining your submission. Our expert facilitators will share insider tips on what makes a proposal stand out to reviewers and resonate with attendees.
What You’ll Learn:- How to choose and frame a compelling topic
- Crafting clear, concise, and engaging abstracts
- Tips for tailoring your proposal to different audiences
- Insight into the MidCamp review process
Ready to submit? Session submissions for MidCamp 2025 are now open! Visit the MidCamp 2025 session submission page for guidelines and start your journey to the stage.
How to Join:Simply join the MidCamp Slack and head over to the #speakers channel on December 12th at 3:00 PM CST. No registration required—just jump in and start collaborating!
Bounteous.com: Upgrading to Drupal 10 (And Beyond) With Composer
FSF Blogs: Free software is vital for the public and state-run infrastructure of a free society
Free software is vital for the public and state-run infrastructure of a free society
Real Python: Continuous Integration and Deployment for Python With GitHub Actions
Creating software is an achievement worth celebrating. But software is never static. Bugs need to be fixed, features need to be added, and security demands regular updates. In today’s landscape, with agile methodologies dominating, robust DevOps systems are crucial for managing an evolving codebase. That’s where GitHub Actions shine, empowering Python developers to automate workflows and ensure their projects adapt seamlessly to change.
GitHub Actions for Python empowers developers to automate workflows efficiently. This enables teams to maintain software quality while adapting to constant change.
Continuous Integration and Continuous Deployment (CI/CD) systems help produce well-tested, high-quality software and streamline deployment. GitHub Actions makes CI/CD accessible to all, allowing automation and customization of workflows directly in your repository. This free service enables developers to execute their software development processes efficiently, improving productivity and code reliability.
In this tutorial, you’ll learn how to:
- Use GitHub Actions and workflows
- Automate linting, testing, and deployment of a Python project
- Secure credentials used for automation
- Automate security and dependency updates
This tutorial will use an existing codebase, Real Python Reader, as a starting point for which you’ll create a CI/CD pipeline. You can fork the Real Python Reader code on GitHub to follow along. Be sure to deselect the Copy the master branch only option when forking. Alternatively, if you prefer, you can build your own Real Python Reader using a previous tutorial.
In order to get the most out of this tutorial, you should be comfortable with pip, building Python packages, Git, and have some familiarity with YAML syntax.
Before you dig into GitHub Actions, it may be helpful to take a step back and learn about the benefits of CI/CD. This will help you understand the kinds of problems that GitHub Actions can solve.
Get Your Code: Click here to download the free sample code you’ll use to learn about CI/CD for Python With GitHub Actions.
Take the Quiz: Test your knowledge with our interactive “GitHub Actions for Python” quiz. You’ll receive a score upon completion to help you track your learning progress:
Interactive Quiz
GitHub Actions for PythonIn this quiz, you'll test your understanding of GitHub Actions for Python. By working through this quiz, you'll revisit how to use GitHub Actions and workflows to automate linting, testing, and deployment of a Python project.
Unlocking the Benefits of CI/CDContinuous Integration (CI) and Continuous Deployment (CD), commonly known as CI/CD, are essential practices in modern software development. These practices automate the integration of code changes, the execution of tests, and the deployment of applications. This helps teams and open-source contributors to deliver code changes more frequently in a reliable and structured way.
Moreover, when publishing open-source Python packages, CI/CD will ensure that all pull requests (PRs) and contributions to your package will meet the needs of the project while standardizing the code quality.
Note: To learn more about what a pull request is and how to create one, you can read GitHub’s official documentation.
More frequent deployments with smaller code changes reduce the risk of unintended breaking changes that can occur with larger, more complex releases. For example, even though developers can format all code using the same linting tools and rules, policy can automatically block PRs from being merged if the code’s tests don’t pass.
In the next section, you’ll learn how GitHub Workflows can help you implement CI/CD on a repository hosted on GitHub.
Exploring GitHub WorkflowsGitHub Workflows are a powerful feature of GitHub Actions. They allow you to define custom automation workflows for your repositories. Whether you want to build, test, or deploy your code, GitHub Workflows provide a flexible and customizable solution that any project on GitHub can use for free, whether the repository is public or private.
Even though there are many CI/CD providers, GitHub Actions has become the default among open-source projects on GitHub because of its expansive ecosystem, flexibility, and low or no cost.
Anatomy of a Workflow FileWorkflow files are declaratively written YAML files with a predefined structure that must be adhered to for a workflow to run successfully. Your YAML workflow files are stored and defined in a .github/workflows/ folder in your project’s root directory.
Your workflow folder can have multiple workflow files, each of which will perform a certain task. You can name these workflow files anything you’d like. However, for the sake of simplicity and readability, it’s common practice to name them after the tasks they achieve, such as test.yml.
Each file has a few elements that are required, but many, many more that are optional. The GitHub Actions documentation is thorough and well-written, so be sure to check it out after you’ve finished reading this tutorial.
There are three main parts that make up the bulk of a workflow file: triggers, jobs, and steps. You’ll cover these in the next sections.
Workflow Triggers Read the full article at https://realpython.com/github-actions-python/ »[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
The Drop Times: Automating Single Directory Component Creation in Drupal with YAML Script
Bits from Debian: OpenStreetMap migrates to Debian 12
You may have seen this toot announcing OpenStreetMap's migration to Debian on their infrastructure.
🚀 After 18 years on Ubuntu, we've upgraded the @openstreetmap servers to Debian 12 (Bookworm). 🌍 openstreetmap.org is now faster using Ruby 3.1. Onward to new mapping adventures! Thank you to the team for the smooth transition. #OpenStreetMap #Debian 🤓
We spoke with Grant Slater, the Senior Site Reliability Engineer for the OpenStreetMap Foundation. Grant shares:
Why did you choose Debian?
There is a large overlap between OpenStreetMap mappers and the Debian community. Debian also has excellent coverage of OpenStreetMap tools and utilities, which helped with the decision to switch to Debian.
The Debian package maintainers do an excellent job of maintaining their packages - e.g.: osm2pgsql, osmium-tool etc.
Part of our reason to move to Debian was to get closer to the maintainers of the packages that we depend on. Debian maintainers appear to be heavily invested in the software packages that they support and we see critical bugs get fixed.
What drove this decision to migrate?
OpenStreetMap.org is primarily run on actual physical hardware that our team manages. We attempt to squeeze as much performance from our systems as possible, with some services being particularly I/O bound. We ran into some severe I/O performance issues with kernels ~6.0 to < ~6.6 on systems with NVMe storage. This pushed us onto newer mainline kernels, which led us toward Debian. On Debian 12 we could simply install the backport kernel and the performance issues were solved.
How was the transition managed?
Thankfully we manage our server setup nearly completely with code. We also use Test Kitchen with inspec to test this infrastructure code. Tests run locally using Podman or Docker containers, but also run as part of our git code pipeline.
We added Debian as a test target platform and fixed up the infrastructure code until all the tests passed. The changes required were relatively small, simple package name or config filename changes mostly.
What was your timeline of transition?
In August 2024 we moved the www.openstreetmap.org Ruby on Rails servers across to Debian. We haven't yet finished moving everything across to Debian, but we will upgrade the rest when it makes sense. Some systems may wait until the next hardware upgrade cycle.
Our focus is to build a stable and reliable platform for OpenStreetMap mappers.
How has the transition from another Linux distribution to Debian gone?
We are still in the process of fully migrating between Linux distributions, but we can share that we recently moved our frontend servers to Debian 12 (from Ubuntu 22.04) which bumped the Ruby version from 3.0 to 3.1 which allowed us to also upgrade the version of Ruby on Rails that we use for www.openstreetmap.org.
We also changed our chef code for managing the network interfaces from using netplan (default in Ubuntu, made by Canonical) to directly using systemd-networkd to manage the network interfaces, to allow commonality between how we manage the interfaces in Ubuntu and our upcoming Debian systems. Over the years we've standardised our networking setup to use 802.3ad bonded interfaces for redundancy, with VLANs to segment traffic; this setup worked well with systemd-networkd.
We use netboot.xyz for PXE networking booting OS installers for our systems and use IPMI for the out-of-band management. We remotely re-installed a test server to Debian 12, and fixed a few minor issues missed by our chef tests. We were pleasantly surprised how smoothly the migration to Debian went.
In a few limited cases we've used Debian Backports for a few packages where we've absolutely had to have a newer feature. The Debian package maintainers are fantastic.
What definitely helped us is our code is libre/free/open-source, with most of the core OpenStreetMap software like osm2pgsql already in Debian and well packaged.
In some cases we do run pre-release or custom patches of OpenStreetMap software; with Ubuntu we used launchpad.net's Personal Package Archives (PPA) to build and host deb repositories for these custom packages. We were initially perplexed by the myriad of options in Debian (see this list - eeek!), but received some helpful guidance from a Debian contributor and we now manage our own deb repository using aptly. For the moment we're currently building deb packages locally and pushing to aptly; ideally we'd like to replace this with a git driven pipeline for building the custom packages in the future.
Thank you for taking the time to share your experience with us.
Thank you to all the awesome people who make Debian!
We are overjoyed to share this in-use case which demonstrates our commitment to stability, development, and long term support. Debian offers users, companies, and organisations the ability to plan, scope, develop, and maintain at their own pace using a rock solid stable Linux distribution with responsive developers.
Does your organisation use Debian in some capacity? We would love to hear about it and your use of 'The Universal Operating System'. Reach out to us at Press@debian.org - we would be happy to add your organisation to our 'Who's Using Debian?' page and to share your story!
About DebianThe Debian Project is an association of individuals who have made common cause to create a free operating system. This operating system that we have created is called Debian. Installers and images, such as live systems, offline installers for systems without a network connection, installers for other CPU architectures, or cloud instances, can be found at Getting Debian.
Kdenlive Café in December
The next Kdenlive Café will be on the 3rd of December at 8 PM UTC.
Come chat with the team!
Join us at: https://meet.kde.org/b/far-twm-ebr
The post Kdenlive Café in December appeared first on Kdenlive.