FLOSS Project Planets

LN Webworks: How To Create Drupal Custom Entity: Step By Step Guide

Planet Drupal - Mon, 2024-04-08 06:15

Custom Entities are a powerful tool for building complex web applications and content management systems. Entities in Drupal provide a standardized way to store and manipulate data. Custom entity types in Drupal empower developers to define custom functionality, enhance performance, and maintain full control over data structures, supplementing the numerous built-in entity types.

Here are the steps for creating a custom entity.

Drupal 10 Custom Entity Development in easy steps:

Step 1: Create a custom folder for your module.

                                                     

Choose a short name or machine name for your module.

Categories: FLOSS Project Planets

Golems GABB: Innovative Methods of Integrating Drupal with Other Systems to Expand Your Website's Capabilities

Planet Drupal - Mon, 2024-04-08 05:42
Innovative Methods of Integrating Drupal with Other Systems to Expand Your Website's Capabilities Editor Mon, 04/08/2024 - 12:42

Given the variety of tools and techniques Drupal offers, it is a must to estimate your business needs first. AI, VR, AR, blockchain, and other technologies will keep reshaping industrial processes, so your task is to ensure the overall Drupal site’s scalability and versatility. 
Businesses of any calibre won’t achieve excellent results if they don’t align the server-side and client-side aspects of website development. Expanding website capabilities with Drupal integration will help you keep the momentum and improve online experiences for your audiences. 
The demand for mobile-first designs, as well as emerging technologies and e-commerce growth, make surviving in the niche without implementing innovative methods of performance and communication impossible. Stay tuned to explore the palette of tools and techniques to level up the standards of website architecture and efficiency for your business.

Categories: FLOSS Project Planets

Python Insider: Python 3.11.9 is now available

Planet Python - Mon, 2024-04-08 00:50

  


 This is the last bug fix release of Python 3.11 

This is the ninth maintenance release of Python 3.11

Python 3.11.9 is the newest major release of the Python programming language, and it contains many new features and optimizations. Get it here:

https://www.python.org/downloads/release/python-3119/

Major new features of the 3.11 series, compared to 3.10

Among the new major new features and changes so far:

  • PEP 657 – Include Fine-Grained Error Locations in Tracebacks
  • PEP 654 – Exception Groups and except*
  • PEP 673 – Self Type
  • PEP 646 – Variadic Generics
  • PEP 680 – tomllib: Support for Parsing TOML in the Standard Library
  • PEP 675 – Arbitrary Literal String Type
  • PEP 655 – Marking individual TypedDict items as required or potentially-missing
  • bpo-46752 – Introduce task groups to asyncio
  • PEP 681 – Data Class Transforms
  • bpo-433030– Atomic grouping ((?>…)) and possessive quantifiers (*+, ++, ?+, {m,n}+) are now supported in regular expressions.
  • The Faster Cpython Project is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See Faster CPython for details.

More resources

And now for something completely different

A kugelblitz is a theoretical astrophysical object predicted by general relativity. It is a concentration of heat, light or radiation so intense that its energy forms an event horizon and becomes self-trapped. In other words, if enough radiation is aimed into a region of space, the concentration of energy can warp spacetime so much that it creates a black hole. This would be a black hole whose original mass–energy was in the form of radiant energy rather than matter, however as soon as it forms, it is indistinguishable from an ordinary black hole.

We hope you enjoy the new releases!Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation.

https://www.python.org/psf/

Your friendly release team,
Ned Deily @nad 
Steve Dower @steve.dower 
Pablo Galindo Salgado @pablogsal

Categories: FLOSS Project Planets

Salsa Digital: Drupal stats in Australian government jurisdictions

Planet Drupal - Mon, 2024-04-08 00:14
Drupal use in the Australian public sector At the recent DrupalSouth 2024, Sean Hamlin from  amazee.io took us through some enlightening stats on CMS use for Australian government websites. This was as a follow-on to stats he provided at DrupalSouth 2022 . Once again, he analysed Drupal use for each state/territory and also for Federal Government sites.  After briefly highlighting his methodology, Sean dived into the stats.  Victoria The breakdown of CMSs used by government websites in Victoria is as follows: Drupal (.vic.gov.au) — 32.2% (based on aggregation by score)  Unknown — 20%  SquizMatrix — 15.5% Opencities — 9.4% New South Wales For New South Wales, the most used CMSs by the government are: Drupal (nsw.gov.au) — 23.7% Unknown — 19.5% SquizMatrix — 15.
Categories: FLOSS Project Planets

stow @ Savannah: GNU Stow 2.4.0 released

GNU Planet! - Sun, 2024-04-07 19:22

Stow 2.4.0 has been released. This release contains some much-wanted bug-fixes — specifically, fixing the --dotfiles option to work with dot-foo directories, and avoiding a spurious warning when unstowing. There were also very many clean-ups and improvements, mostly internal and not visible to users. See http://git.savannah.gnu.org/cgit/stow.git/tree/NEWS for more details.

Categories: FLOSS Project Planets

Thorsten Alteholz: My Debian Activities in March 2024

Planet Debian - Sun, 2024-04-07 07:56
FTP master

This month I accepted 147 and rejected 12 packages. The overall number of packages that got accepted was 151.

If you file an RM bug, please do check whether there are reverse dependencies as well and file RM bugs for them. It is annoying and time-consuming when I have to do the moreinfo dance.

Debian LTS

This was my hundred-seventeenth month that I did some work for the Debian LTS initiative, started by Raphael Hertzog at Freexian.

During my allocated time I uploaded:

  • [DLA 3770-1] libnet-cidr-lite-perl security update for one CVE to fix IP parsing and ACLs based on the result
  • [#1067544] Bullseye PU bug for libmicrohttpd
  • Unfortunately XZ happened at the end of month and I had to delay/intentionally delayed other uploads: they will appear as DLA-3781-1 and DLA-3784-1 in April

I also continued to work on qtbase-opensource-src and last but not least did a week of FD.

Debian ELTS

This month was the sixty-eighth ELTS month. During my allocated time I uploaded:

  • [ELA-1062-1]libnet-cidr-lite-perl security update for one CVE to improve parsing of IP addresses in Jessie and Stretch
  • Due to XZ I also delayed the uploads here. They will appear as ELA-1069-1 and DLA-1070-1 in April

I also continued on an update for qtbase-opensource-src in Stretch (and LTS and other releases as well) and did a week of FD.

Debian Printing

This month I uploaded new upstream or bugfix versions of:

This work is generously funded by Freexian!

Debian Astro

This month I uploaded a new upstream or bugfix version of:

Debian IoT

This month I uploaded new upstream or bugfix versions of:

Debian Mobcom

This month I uploaded a new upstream or bugfix version of:

misc

This month I uploaded new upstream or bugfix versions of:

Categories: FLOSS Project Planets

The Drop Times: The Drop Times Seeks Volunteers for DrupalCon Portland 2024 Coverage

Planet Drupal - Sat, 2024-04-06 13:54
Join The Drop Times at DrupalCon Portland 2024! We're seeking passionate volunteers to capture the excitement, insights, and moments that make this event unforgettable. From live updates to interviews and photo documentation, be part of our team and showcase the best of DrupalCon North America 2024! Sign up now to get involved.
Categories: FLOSS Project Planets

John Goerzen: Facebook is Censoring Stories about Climate Change and Illegal Raid in Marion, Kansas

Planet Debian - Sat, 2024-04-06 10:00

It is, sadly, not entirely surprising that Facebook is censoring articles critical of Meta.

The Kansas Reflector published an artical about Meta censoring environmental articles about climate change — deeming them “too controversial”.

Facebook then censored the article about Facebook censorship, and then after an independent site published a copy of the climate change article, Facebook censored it too.

The CNN story says Facebook apologized and said it was a mistake and was fixing it.

Color me skeptical, because today I saw this:

Yes, that’s right: today, April 6, I get a notification that they removed a post from August 12. The notification was dated April 4, but only showed up for me today.

I wonder why my post from August 12 was fine for nearly 8 months, and then all of a sudden, when the same website runs an article critical of Facebook, my 8-month-old post is a problem. Hmm.

Riiiiiight. Cybersecurity.

This isn’t even the first time they’ve done this to me.

On September 11, 2021, they removed my post about the social network Mastodon (click that link for screenshot). A post that, incidentally, had been made 10 months prior to being removed.

While they ultimately reversed themselves, I subsequently wrote Facebook’s Blocking Decisions Are Deliberate — Including Their Censorship of Mastodon.

That this same pattern has played out a second time — again with something that is a very slight challenege to Facebook — seems to validate my conclusion. Facebook lets all sort of hateful garbage infest their site, but anything about climate change — or their own censorship — gets removed, and this pattern persists for years.

There’s a reason I prefer Mastodon these days. You can find me there as @jgoerzen@floss.social.

So. I’ve written this blog post. And then I’m going to post it to Facebook. Let’s see if they try to censor me for a third time. Bring it, Facebook.

Categories: FLOSS Project Planets

Drupixels: Slow Drupal Permissions Page? Use Better Permissions Page Module!

Planet Drupal - Sat, 2024-04-06 04:38
Discover how the Better Permissions Page module simplifies permission management in Drupal by replacing the default permissions page, improving performance, and efficiently updating permissions and roles.
Categories: FLOSS Project Planets

February/March in KDE Itinerary

Planet KDE - Sat, 2024-04-06 04:00

It has been two exciting months since the last update on KDE Itinerary again, with new vehicle and train coach amenity information, DST changes in the timeline, progress on indoor routing and most notably the founding of the Transitous project.

New Features Train and coach amenity information

The library we use for public transport data now has a much more elaborate data model for vehicle features. That’s general comfort feature like air conditioning or Wi-Fi but also things specifically relevant when traveling with small children, a bike or a wheelchair. These can also be qualified by availability (e.g. if those need a special reservation) and can be marked as disrupted.

Itinerary makes use of this in the train coach layout view, where it’s now possible to tap on a coach for a more detailed description.

Coach feature details in Itinerary's train coach layout view.

Another place where this is used is anything showing results from journey or departure searches, such as when planning a new train trip. While all routing services provide some of this information, the level of detail can vary greatly though.

Vehicle features in journey search results.

Since this is now available in a machine-readable form, it also becomes conceivable to allow configuring more detailed traveler profiles so Itinerary can show the information most relevant to you more prominently, or take this into consideration e.g. when automatically selecting transfer suggestions.

Daylight saving time information

Switching to and from daylight saving time happens at different times in different locations (if at all), therefore Itinerary now also displays an information for upcoming daylight saving time changes in the timeline, similar as it already does for e.g. timezone changes.

Daylight saving time information in Itinerary's timeline. Infrastructure Work Transitous

The probably most significant development on the infrastructure side is the appearance of Transitous. That’s a project which started at FOSDEM 2024 barely two months ago with the aim of setting up a community-run free and open public transport routing service. It has been growing rapidly and is meanwhile a collaboration from people from many different FOSS and Open Data projects and communities.

Current Transitous coverage for long-distance travel in Europe.

While not even having all the basic features completed yet, it nevertheless already provides value by covering a few countries where we didn’t have any public transport data at all before. Starting with 24.05 KPublicTransport will have support for Transitous enabled by default, and thus it will also become available in Itinerary and KTrip.

Unlike with vendor-operated or otherwise proprietary services it’s now possible to expand public transport data coverage ourselves, assuming publicly available GTFS feeds at least.

Indoor routing

Work on indoor routing for our train station, airport or event venue maps also continued, with the focus on turning the previously shown demo that was able to find a path from A to B into something that does that reliably and matching human expectations, which is the bulk of the work here.

Examples of this include not taking “shortcuts” through paths you shouldn’t usually take (e.g. emergency exists, or walking through conference rooms/lecture halls as pictured below), but also ensuring robustness against imperfect or incomplete map data.

Shortest path (left), preferring corridors (right).

Some of this also involves clarifying or extending the OSM data model, and onsite visits to inspect challenging locations.

Fixes & Improvements Travel document extractor
  • New or improved travel document extractors for AMSBus, ANA, Deutsche Bahn, Eckerö Line, Elron, European Sleeper, Eurostar, Eventim, Finnair, Flibco, Leo Express, LTG Link, Moongate, National Express, Pasažieru vilciens, Salzbergwerk, SNCF, Thalys, ti.to, Trenitalia and UK national railways.
  • Added support for yet another variant of PDF raster images for barcode detection.
  • Improved generic extractors for flight boarding passes as well as ERA FCB and VDV train tickets.
  • Fixed the schema.org semantic annotations in the OSM event calendar.
  • Consider GIF files as well when searching for barcodes.

All of this has been made possible thanks to your travel document donations!

Public transport data
  • Fixed Deutsche Bahn Hafas searches sometimes not including replacement trains.
  • Fixed misdetected train coach types from UIC coach numbers.
  • Updated coverage metadata from the Transport API Repository.
  • Fixed caching of location queries and negative journey query results.
  • Improved support for arrival query result paging.
  • Updated support for ÖBB coach layout data.
  • Fixed train coach layout queries using times in the wrong timezone.
Itinerary app
  • Fixed barcode scanning on Android, caused by a regression in Qt 6.6.2 (affects all KDE apps, not just Itinerary).
  • Prevent overly large Apple Wallet pass footer images from messing up the layout.
  • Fix editing of times in AM/PM format.
  • Remember the last used folder in trip group export file dialogs.
  • Suggest meaningful file names for exporting trip groups.
  • Allow to copy the program membership number on reservation pages as well.
  • Added enough space at the end of the journey details view so floating buttons don’t overlap relevant content.
  • Added floating button to timeline page to navigate to the current element and for manually adding entries.
  • Fixed current ticket selection for elements without known arrival times.
  • Fixed retaining journey notes/vehicle layouts when getting partial trip updates.
  • Fixed displaying of departure notes for train trips.
  • Fixed displaying of public transport departure disruptions.
How you can help

Feedback and travel document samples are very much welcome, as are all other forms of contributions. Feel free to join us in the KDE Itinerary Matrix channel.

Categories: FLOSS Project Planets

This week in KDE: real modifier-only shortcuts and cropping in Spectacle

Planet KDE - Sat, 2024-04-06 00:56

For years KWin has offered modifier-only shortcut handling via an obscure and undocumented method of editing the kwinrc file. Well, no more: in Plasma 6.1, KDE’s shortcut choosers will accept lone modifier keys natively! This makes it much easier to, for example, re-bind what the Meta key does: now you can easily make it open Overview, KRunner, or anything else simply by assigning it directly to that something else. This work required extensive re-plumbing throughout KDE’s software stack and was undertaken by Yifan Zhu, closing multiple Bugzilla tickets in the process—some fairly old. Thanks a lot, Yifan! (Link 1, link 2, link 3, link 4, link 5, and link 6)

But that’s not all! Though bug-fixing is eternal, we’ve largely gotten over the hump for Plasma 6.0, and I’ve noticed that features and UI improvement have occupied more of people’s attention recently. So let’s start with a much-requested one…

New Features

Spectacle regains a Crop tool, this time integrated internally rather than coming from a 3rd-party annotations library. This also happens to fix a related bug (Noah Davis, Spectacle 24.05. Link 1 and link 2):

For laptops with RGB-backlit keyboards, Plasma has gained the ability to keep the backlight color in sync with the active accent color! And support for custom colors is coming too (Natalie Clarius, Plasma 6.1. Link 1 and link 2):

https://i.imgur.com/zlsaJlX.mp4

The new automatic crash reporter now gives you the option to let it always download debug symbols in the background to improve the crash reports it generates (Harald Sitter, Plasma 6.1. Link)

Going along with the theme of modifier-only shortcuts, you can now make an unused mouse button simulate pressing a modifier key alone (David Redondo, Plasma 6.1. Link)

Even though Snaps are supposed to auto-update, Discover has gained the ability to let you manually update them if desired (Kevin Ottens, Plasma 6.1. Link)

UI Improvements

Dolphin now shows a visible error message when you use a keyboard shortcut to trigger an action that can’t be performed in the current context, like cutting a file in a read-only folder (Jin Liu, Dolphin 24.05. Link):

In Elisa, you can now switch between list and grid views as you see fit (Jack Hill, Elisa 24.05. Link):

In Elisa, you can now search for albums on the Tracks page (Karl Hoffman, Elisa 24.05. Link)

You can now select multiple wallpapers in Plasma’s “add new wallpaper” dialog (Sahil Arora, Plasma 6.0.4. Link)

Changed Breeze-themed radio buttons and checkboxes to use the “Button” color role as most other interactive UI elements already do, which not only improves visual consistency, but also fixes a visual glitch in QtQuick-based software where these UI elements would have the wrong color some of the time (Akseli Lahtinen, Frameworks 6.1 and Plasma 6.1. Link 1, link 2, and link 3)

List headers in Kickoff now use the standard list header style seen in QtQuick-based KDE apps, which also necessitated creating a version of that component suitable for Plasma, so expect to see it showing up in more places too (me: Nate Graham, Plasma 6.1. Link 1 and link 2):

The Plasma Digital Clock widget’s holiday list picker no longer elides long text; instead it wraps the text, since there’s plenty of space to show it in the long already-scrollable list (Ivan Tkachenko, Plasma 6.1. Link)

Bug Fixes

Okular no longer asks you for a password to open encrypted PDF documents where the encryption isn’t actually applied to simply opening them (Nicolas Fella, sponsored by TU Dresden, Okular 24.02.2. Link)

Fixed a set of related crashes in Plasma that appear to have been a subtle side effect of the recent fix to make apps in Kickoff’s favorite grid disappear immediately when uninstalled (Fushan Wen, Plasma 6.0.4. Link)

Fixed another case where Plasma could crash when you plugged in a new screen (Fushan Wen, Plasma 6.0.4. Link 1 and link 2)

Fixed a rare Plasma crash that could happen when clicking on certain System Tray icons (Fushan Wen, Plasma 6.0.4. Link)

Fixed a case where Spectacle could crash after ending a screen recording when using certain GPU hardware (Fabian Vogt, Plasma 6.0.4. Link)

Fixed bug that had broken the ability to log out within 60 seconds of logging in when using Plasma’s systemd-enabled startup process (Harald Sitter, Plasma 6.0.4. Link)

Fixed an issue that caused two-finger touchpad taps on the Task Manager to not open a context menu with certain, shall we say, “less than premium” touchpad hardware (Fushan Wen, Plasma 6.0.4. Link)

Contributed code hardening for four additional crashes picked up by KDE’s automatic crash reporting system, which as you can tell is proving quite useful! (Fushan Wen again; he’s just that amazing! Plasma 6.0.4. Link 1, link 2, link 3, and link 4)

Fixed the date information in the tooltips of various clock widgets not being localized correctly (Albert Astals Cid, Plasma 6.0.4. Link 1 and link 2)

Fixed a variety of additional weird issues with mouse cursors in video games on Wayland (Xaver Hugl, Plasma 6.1. Link 1 and link 2)

Fixed some visual glitches that could happen on Wayland when you resize certain types of window that open in a maximized state (Ser Freeman, Plasma 6.1. Link)

Other bug information of note:

Performance & Technical

Spectacle now takes screenshots faster when used outside of Plasma and KWin on X11 (Konstantin Kharlamov, Spectacle 24.02.2. Link)

By default, Partition manager now mounts volumes (other than / and /home) with the nofail flag so they don’t block boot-up when not available for some reason (Thomas Bertels, Partition Manager 24.05. Link)

Fixed a memory leak in Plasma’s Networks widget (Fushan Wen, Plasma 6.0.4. Link)

Custom QML layouts for lock screens in Global Themes are no longer honored, as this is too security-sensitive (Marco Martin, Plasma 6.1. Link 1, link 2, link 3, and link 4)

The Dialog Parent effect (the thing that makes windows get dimmed when a child dialog window is open) now works on Wayland (Carlos Garnacho and David Redondo, Plasma 6.1 with Qt 6.8. Link)

Did a major code-quality overhaul of the Plasma Digital Clock and Calendar widgets, which fixed a bunch of fragility, warnings, and some minor glitches, with more to come soon (Ivan Tkachenko, Plasma 6.1. Link)

Automation & Systematization

Wrote a tutorial on how to publish your Android-compatible KDE app on the Google Play store (Ingo Klöcker, link)

…And Everything Else

This blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.

How You Can Help

KDE has become important in the world, and your time and labor have helped to bring it there! But as we grow, it’s going to be equally important that this stream of labor be made sustainable, which primarily means paying for it. Right now the vast majority of KDE runs on labor that KDE e.V. didn’t pay for, and that’s a problem. We’ve taken steps to change this with paid technical contractors—but those steps are small due to limited financial resources. If you’d like to help change that, consider donating today!

Otherwise, visit https://community.kde.org/Get_Involved to discover other ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

Categories: FLOSS Project Planets

Junichi Uekawa: Trying to explain analogue clock.

Planet Debian - Fri, 2024-04-05 23:37
Trying to explain analogue clock. It's hard to explain. Tried adding some things for affordance, and it is still not enough. So it's not obvious which arm is the hour and which arm is the minute. analog clock

Categories: FLOSS Project Planets

Python Morsels: Python's http.server module

Planet Python - Fri, 2024-04-05 19:41

Use Python's http.server module to serve up a static website on your own machine.

Table of contents

  1. A directory trees of index.html files
  2. Serving up HTML files with http.server
  3. Customizing http.server with CLI arguments
  4. Using http.server as a module
  5. Use python -m http.server for a local HTTP server

A directory trees of index.html files

We have a directory here that represents a static website:

~/comprehensions/_build/dirhtml $ ls index.html index.html

We not only have an index.html file, but also a bunch of sub-directories, each with their own index.html file:

~/comprehensions/_build/dirhtml $ ls generator-expressions index.html

The only way to really navigate this website locally is to serve up these files using some sort of HTTP server that is aware of these index files.

Python comes bundled with an HTTP server that we can use. It's called http.server.

Serving up HTML files with http.server

If we run this module …

Read the full article: https://www.pythonmorsels.com/http-server/
Categories: FLOSS Project Planets

Paul Wise: FLOSS Activities March 2024

Planet Debian - Fri, 2024-04-05 19:24
Focus

This month I didn't have any particular focus. I just worked on issues in my info bubble.

Changes Issues Administration
  • Debian wiki: approve accounts
Communication
  • Respond to queries from Debian users and contributors on the mailing lists and IRC
Sponsors

The SWH work was sponsored. All other work was done on a volunteer basis.

Categories: FLOSS Project Planets

Dirk Eddelbuettel: RcppArmadillo 0.12.8.2.0 on CRAN: Upstream Fix

Planet Debian - Fri, 2024-04-05 18:12

Armadillo is a powerful and expressive C++ template library for linear algebra and scientific computing. It aims towards a good balance between speed and ease of use, has a syntax deliberately close to Matlab, and is useful for algorithm development directly in C++, or quick conversion of research code into production environments. RcppArmadillo integrates this library with the R environment and language–and is widely used by (currently) 1136 other packages on CRAN, downloaded 33.5 million times (per the partial logs from the cloud mirrors of CRAN), and the CSDA paper (preprint / vignette) by Conrad and myself has been cited 578 times according to Google Scholar.

This release brings a new upstream bugfix release Armadillo 12.8.2 prepared by Conrad two days ago. It took the usual day to noodle over 1100+ reverse dependencies and ensure two failures were independent of the upgrade (i.e., “no change to worse” in CRAN parlance). It took CRAN another because we hit a random network outage for (spurious) NOTE on a remote URL, and were then caught in the shrapnel from another large package ecosystem update spuriously pointing some build failures that were due to a missing rebuild to us. All good, as human intervention comes to the rescue.

The set of changes since the last CRAN release follows.

Changes in RcppArmadillo version 0.12.8.2.0 (2024-04-02)
  • Upgraded to Armadillo release 12.8.2 (Cortisol Injector)

    • Workaround for FFTW3 header clash

    • Workaround in testing framework for issue under macOS

    • Minor cleanups to reduce code bloat

    • Improved documentation

Courtesy of my CRANberries, there is a diffstat report relative to previous release. More detailed information is on the RcppArmadillo page. Questions, comments etc should go to the rcpp-devel mailing list off the Rcpp R-Forge page.

If you like this or other open-source work I do, you can sponsor me at GitHub.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

The Drop Times: Crafting the Future of Web Development: A Conversation with Adrian Ababei

Planet Drupal - Fri, 2024-04-05 16:09
Discover the journey of Adrian Ababei, Senior Drupal Architect and CEO of OPTASY, as he shares insights into web development and Drupal architecture, alongside an overview of OPTASY's mission and services.
Categories: FLOSS Project Planets

Bits from Debian: apt install dpl-candidate: Sruthi Chandran

Planet Debian - Fri, 2024-04-05 14:36

The Debian Project Developers will shortly vote for a new Debian Project Leader known as the DPL.

The DPL is the official representative of representative of The Debian Project tasked with managing the overall project, its vision, direction, and finances.

The DPL is also responsible for the selection of Delegates, defining areas of responsibility within the project, the coordination of Developers, and making decisions required for the project.

Our outgoing and present DPL Jonathan Carter served 4 terms, from 2020 through 2024. Jonathan shared his last Bits from the DPL post to Debian recently and his hopes for the future of Debian.

Recently, we sat with the two present candidates for the DPL position asking questions to find out who they really are in a series of interviews about their platforms, visions for Debian, lives, and even their favorite text editors. The interviews were conducted by disaster2life (Yashraj Moghe) and made available from video and audio transcriptions:

  • Andreas Tille [Interview]
  • Sruthi Chandran [this document]

Voting for the position starts on April 6, 2024.

Editors' note: This is our official return to Debian interviews, readers should stay tuned for more upcoming interviews with Developers and other important figures in Debian as part of our "Meet your Debian Developer" series. We used the following tools and services: Turboscribe.ai for the transcription from the audio and video files, IRC: Oftc.net for communication, Jitsi meet for interviews, and Open Broadcaster Software (OBS) for editing and video. While we encountered many technical difficulties in the return to this process, we are still able and proud to present the transcripts of the interviews edited only in a few areas for readability.

2024 Debian Project Leader Candidate: Sruthi Chandran

Sruthi's interview

Hi Sruthi, so for the first question, who are you and could you tell us a little bit about yourself?

[Sruthi]:

I usually talk about me whenever I am talking about answering the question who am I, I usually say like I am a librarian turned free software enthusiast and a bin developer. So I had no technical background and I learned, I was introduced to free software through my husband and then I learned Debian packaging, and eventually I became a Debian developer. So I always give my example to people who say I am not technically inclined, I don't have technical background so I can't contribute to free software.

So yeah, that's what I refer to myself.

For the next question, could you tell me what do you do in Debian, and could you mention your story up until here today?

[Sruthi]:

Okay, so let me start from my initial days in Debian. I started contributing to Debian, my first contribution was a Tibetan font. We went to a Tibetan place and they were saying they didn't have a font in Linux.

So that's how I started contributing. Then I moved on to Ruby packages, then I have some JavaScript and Go packages, all dependencies of GitLab. So I was involved with maintaining GitLab for some time, now I'm not very active there.

But yeah, so GitLab was the main package I was contributing to since I contributed since 2016 to maybe like 2020 or something. Later I have come [over to] packaging. Now I am part of some of the teams, delegated teams, like community team and outreach team, as well as the Debconf committee. And the biggest, I think, my activity in Debian, I would say is organizing Debconf 2023. So it was a great experience and yeah, so that's my story in Debian.

So what are three key terms about you and your candidacy?

[Sruthi]:

Okay, let me first think about it. For candidacy, I can start with diversity is one point I started expressing from the first time I contested for DPL. But to be honest, that's the main point I want to bring.

[Yashraj]:

So for diversity, if you could break down your thoughts on diversity and make them, [about] your three points including diversity.

[Sruthi]:

So in addition to, eventually when starting it was just diversity. Now I have like a bit more ideas, like community, like I want to be a leader for the Debian community. More than, I don't know, maybe people may not agree, but I would say I want to be a leader of Debian community rather than a Debian operating system.

I connect to community more and third point I would say.

The term of a DPL lasts for an year. So what do you think during, what would you try to do during that, that you can't do from your position now?

[Sruthi]:

Okay. So I, like, I am very happy with the structure of Debian and how things work in Debian. Like you can do almost a lot of things, like almost all things without being a DPL.

Whatever change you want to bring about or whatever you want to do, you can do without being a DPL. Anyone, like every DD has the same rights. Only things I feel [the] DPL has hold on are mainly the budget or the funding part, which like, that's where they do the decision making part.

And then comes like, and one advantage of DPL driving some idea is that somehow people tend to listen to that with more, like, tend to give more attention to what DPL is saying rather than a normal DD. So I wanted to, like, I have answered some of the questions on how to, how I plan to do the financial budgeting part, how I want to handle, like, and the other thing is using the extra attention that I get as a DPL, I would like to obviously start with the diversity aspect in Debian. And yeah, like, I, what I want to do is not, like, be a leader and say, like, take Debian to one direction where I want to go, but I would rather take suggestions and inputs from the whole community and go about with that.

So yes, that's what I would say.

And taking a less serious question now, what is your preferred text editor?

[Sruthi]:

Vim.

[Yashraj]:

Vim, wholeheartedly team Vim?

[Sruthi]:

Yes.

[Yashraj]:

Great. Well, this was made in Vim, all the text for this.

[Sruthi]:

So, like, since you mentioned extra data, I'll give my example, like, it's just a fun note, when I started contributing to Debian, as I mentioned, I didn't have any knowledge about free software, like Debian, and I was not used to even using Linux. So, and I didn't have experience with these text editors. So, when I started contributing, I used to do the editing part using gedit.

So, that's how I started. Eventually, I moved to Nano, and once I reached Vim, I didn't move on.

Team Vim. Next question. What, what do you think is the importance of the Debian project in the world today? And where would you like to see it in 10 years, like 10 years into the future?

[Sruthi]:

Okay. So, Debian, as we all know, is referred to as the universal operating system without, like, it is said for a reason. We have hundreds and hundreds of operating systems, like Linux, distributions based on Debian.

So, I believe Debian, like even now, Debian has good influence on the, at least on the Linux or Linux ecosystem. So, what we implement in Debian has, like, is going to affect quite a lot of, like, a very good percentage of people using Linux. So, yes.

So, I think Debian is one of the leading Linux distributions. And I think in 10 years, we should be able to reach a position, like, where we are not, like, even now, like, even these many years after having Linux, we face a lot of problems in newer and newer hardware coming up and installing on them is a big problem. Like, firmwares and all those things are getting more and more complicated.

Like, it should be getting simpler, but it's getting more and more complicated. So, I, one thing I would imagine, like, I don't know if we will ever reach there, but I would imagine that eventually with the Debian, we should be able to have some, at least a few of the hardware developers or hardware producers have Debian pre-installed and those kind of things. Like, not, like, become, I'm not saying it's all, it's also available right now.

What I'm saying is that it becomes prominent enough to be opted as, like, default distro.

What part of Debian has made you And what part of the project has kept you going all through these years?

[Sruthi]:

Okay. So, I started to contribute in 2016, and I was part of the team doing GitLab packaging, and we did have a lot of training workshops and those kind of things within India. And I was, like, I had interacted with some of the Indian DDs, but I never got, like, even through chat or mail.

I didn't have a lot of interaction with the rest of the world, DDs. And the 2019 Debconf changed my whole perspective about Debian. Before that, I wasn't, like, even, I was interested in free software.

I was doing the technical stuff and all. But after DebConf, my whole idea has been, like, my focus changed to the community. Debian community is a very welcoming, very interesting community to be with.

And so, I believe that, like, 2019 DebConf was a for me. And that kept, from 2019, my focus has been to how to support, like, how, I moved to the community part of Debian from there. Then in 2020 I became part of the community team, and, like, I started being part of other teams.

So, these, I would say, the Debian community is the one, like, aspect of Debian that keeps me whole, keeps me held on to the Debian ecosystem as a whole.

Continuing to speak about Debian, what do you think, what is the first thing that comes to your mind when you think of Debian, like, the word, the community, what's the first thing?

[Sruthi]:

I think I may sound like a broken record or something.

[Yashraj]:

No, no.

[Sruthi]:

Again, I would say the Debian community, like, it's the people who makes Debian, that makes Debian special.

Like, apart from that, if I say, I would say I'm very, like, one part of Debian that makes me very happy is the, how the governing system of Debian works, the Debian constitution and all those things, like, it's a very unique thing for Debian. And, and it's like, when people say you can't work without a proper, like, establishment or even somebody deciding everything for you, it's difficult. When people say, like, we have been, Debian has been proving it for quite a long time now, that it's possible.

So, so that's one thing I believe, like, that's one unique point. And I am very proud about that.

What areas do you think Debian is failing in, how can it (that standing) be improved?

[Sruthi]:

So, I think where Debian is failing now is getting new people into Debian. Like, I don't remember, like, exactly the answer. But I remember hearing someone mention, like, the average age of a Debian developer is, like, above 40 or 45 or something, like, exact age, I don't remember.

But it's like, Debian is getting old. Like, the people in Debian are getting old and we are not getting enough of new people into Debian. And that's very important to have people, like, new people coming up.

Otherwise, eventually, like, after a few years, nobody, like, we won't have enough people to take the project forward. So, yeah, I believe that is where we need to work on. We are doing some efforts, like, being part of GSOC or outreachy and having maybe other events, like, local events. Like, we used to have a lot of Debian packaging workshops in India. And those kind of, I think, in Brazil and all, they all have, like, local communities are doing. But we are not very successful in retaining the people who maybe come and try out things.

But we are not very good at retaining the people, like, retaining people who come. So, we need to work on those things. Right now, I don't have a solid answer for that.

But one thing, like, I was thinking about is, like, having a Debian specific outreach project, wherein the focus will be about the Debian, like, starting will be more on, like, usually what happens in GSOC and outreach is that people come, have the, do the contributions, and they go back. Like, they don't have that connection with the Debian, like, Debian community or Debian project. So, what I envision with these, the Debian outreach, the Debian specific outreach is that we have some part of the internship, like, even before starting the internship, we have some sessions and, like, with the people in Debian having, like, getting them introduced to the Debian philosophy and Debian community and Debian, how Debian works.

And those things, we focus on that. And then we move on to the technical internship parts. So, I believe this could do some good in having, like, when you have people you can connect to, you tend to stay back in a project mode.

When you feel something more than, like, right now, we have so many technical stuff to do, like, the choice for a college student is endless. So, if they want, if they stay back for something, like, maybe for Debian, I would say, we need to have them connected to the Debian project before we go into technical parts. Like, technical parts, like, there are other things as well, where they can go and do the technical part, but, like, they can come here, like, yeah.

So, that's what I was saying. Focused outreach projects is one thing. That's just one.

That's not enough. We need more of, like, more ideas to have more new people come up. And I'm very happy with, like, the DebConf thing. We tend to get more and more people from the places where we have a DebConf. Brazil is an example. After the Debconf, they have quite a good improvement on Debian contributors.

And I think in India also, it did give a good result. Like, we have more people contributing and staying back and those things. So, yeah.

So, these were the things I would say, like, we can do to improve.

For the final question, what field in free software do you, what field in free software generally do you think requires the most work to be put into it? What do you think is Debian's part in that field?

[Sruthi]:

Okay. Like, right now, what comes to my mind is the free software licenses parts. Like, we have a lot of free software licenses, and there are non-free software licenses.

But currently, I feel free software is having a big problem in enforcing these licenses. Like, there are, there may be big corporations or like some people who take up the whole, the code and may not follow the whole, for example, the GPL licenses. Like, we don't know how much of those, how much of the free softwares are used in the bigger things.

Yeah, I agree. There are a lot of corporations who are afraid to touch free software. But there would be good amount of free software, free work that converts into property, things violating the free software licenses and those things.

And we do not have the kind of like, we have SFLC, SFC, etc. But still, we do not have the ability to go behind and trace and implement the licenses. So, enforce those licenses and bring people who are violating the licenses forward and those kind of things is challenging because one thing is it takes time, like, and most importantly, money is required for the legal stuff.

And not always people who like people who make small software, or maybe big, but they may not have the kind of time and money to have these things enforced. So, that's a big challenge free software is facing, especially in our current scenario. I feel we are having those, like, we need to find ways how we can get it sorted.

I don't have an answer right now what to do. But this is a challenge I felt like and Debian's part in that. Yeah, as I said, I don't have a solution for that.

But the Debian, so DFSG and Debian sticking on to the free software licenses is a good support, I think.

So, that was the final question, Do you have anything else you want to mention for anyone watching this?

[Sruthi]:

Not really, like, I am happy, like, I think I was able to answer the questions. And yeah, I would say who is watching. I won't say like, I'm the best DPL candidate, you can't have a better one or something.

I stand for a reason. And if you believe in that, or the Debian community and Debian diversity, and those kinds of things, if you believe it, I hope you would be interested, like, you would want to vote for me. That's it.

Like, I'm not, I'll make it very clear. I'm not doing a technical leadership part here. So, those, I can't convince people who want technical leadership to vote for me.

But I would say people who connect with me, I hope they vote for me.

Categories: FLOSS Project Planets

Bits from Debian: apt install dpl-candidate: Andreas Tille

Planet Debian - Fri, 2024-04-05 14:36

The Debian Project Developers will shortly vote for a new Debian Project Leader known as the DPL.

The Project Leader is the official representative of The Debian Project tasked with managing the overall project, its vision, direction, and finances.

The DPL is also responsible for the selection of Delegates, defining areas of responsibility within the project, the coordination of Developers, and making decisions required for the project.

Our outgoing and present DPL Jonathan Carter served 4 terms, from 2020 through 2024. Jonathan shared his last Bits from the DPL post to Debian recently and his hopes for the future of Debian.

Recently, we sat with the two present candidates for the DPL position asking questions to find out who they really are in a series of interviews about their platforms, visions for Debian, lives, and even their favorite text editors. The interviews were conducted by disaster2life (Yashraj Moghe) and made available from video and audio transcriptions:

  • Andreas Tille [this document]
  • Sruthi Chandran [Interview]

Voting for the position starts on April 6, 2024.

Editors' note: This is our official return to Debian interviews, readers should stay tuned for more upcoming interviews with Developers and other important figures in Debian as part of our "Meet your Debian Developer" series. We used the following tools and services: Turboscribe.ai for the transcription from the audio and video files, IRC: Oftc.net for communication, Jitsi meet for interviews, and Open Broadcaster Software (OBS) for editing and video. While we encountered many technical difficulties in the return to this process, we are still able and proud to present the transcripts of the interviews edited only in a few areas for readability.

2024 Debian Project Leader Candidate: Andrea Tille

Andreas' Interview

Who are you? Tell us a little about yourself.

[Andreas]:

How am I? Well, I'm, as I wrote in my platform, I'm a proud grandfather doing a lot of free software stuff, doing a lot of sports, have some goals in mind which I like to do and hopefully for the best of Debian.

And How are you today?

[Andreas]:

How I'm doing today? Well, actually I have some headaches but it's fine for the interview.

So, usually I feel very good. Spring was coming here and today it's raining and I plan to do a bicycle tour tomorrow and hope that I do not get really sick but yeah, for the interview it's fine.

What do you do in Debian? Could you mention your story here?

[Andreas]:

Yeah, well, I started with Debian kind of an accident because I wanted to have some package salvaged which is called WordNet. It's a monolingual dictionary and I did not really plan to do more than maybe 10 packages or so. I had some kind of training with xTeddy which is totally unimportant, a cute teddy you can put on your desktop.

So, and then well, more or less I thought how can I make Debian attractive for my employer which is a medical institute and so on. It could make sense to package bioinformatics and medicine software and it somehow evolved in a direction I did neither expect it nor wanted to do, that I'm currently the most busy uploader in Debian, created several teams around it.

DebianMate is very well known from me. I created the Blends team to create teams and techniques around what we are doing which was Debian TIS, Debian Edu, Debian Science and so on and I also created the packaging team for R, for the statistics package R which is technically based and not topic based. All these blends are covering a certain topic and R is just needed by lots of these blends.

So, yeah, and to cope with all this I have written a script which is routing an update to manage all these uploads more or less automatically. So, I think I had one day where I uploaded 21 new packages but it's just automatically generated, right? So, it's on one day more than I ever planned to do.

What is the first thing you think of when you think of Debian?

Editors' note: The question was misunderstood as the “worst thing you think of when you think of Debian”

[Andreas]:

The worst thing I think about Debian, it's complicated. I think today on Debian board I was asked about the technical progress I want to make and in my opinion we need to standardize things inside Debian. For instance, bringing all the packages to salsa, follow some common standards, some common workflow which is extremely helpful.

As I said, if I'm that productive with my own packages we can adopt this in general, at least in most cases I think. I made a lot of good experience by the support of well-formed teams. Well-formed teams are those teams where people support each other, help each other.

For instance, how to say, I'm a physicist by profession so I'm not an IT expert. I can tell apart what works and what not but I'm not an expert in those packages. I do and the amount of packages is so high that I do not even understand all the techniques they are covering like Go, Rust and something like this.

And I also don't speak Java and I had a problem once in the middle of the night and I've sent the email to the list and was a Java problem and I woke up in the morning and it was solved. This is what I call a team. I don't call a team some common repository that is used by random people for different packages also but it's working together, don't hesitate to solve other people's problems and permit people to get active.

This is what I call a team and this is also something I observed in, it's hard to give a percentage, in a lot of other teams but we have other people who do not even understand the concept of the team. Why is working together make some advantage and this is also a tough thing. I [would] like to tackle in my term if I get elected to form solid teams using the common workflow. This is one thing.

The other thing is that we have a lot of good people in our infrastructure like FTP masters, DSA and so on. I have the feeling they have a lot of work and are working more or less on their limits, and I like to talk to them [to ask] what kind of change we could do to move that limits or move their personal health to the better side.

The DPL term lasts for a year, What would you do during that you couldn't do now?

[Andreas]:

Yeah, well this is basically what I said are my main issues. I need to admit I have no really clear imagination what kind of tasks will come to me as a DPL because all these financial issues and law issues possible and issues [that] people who are not really friendly to Debian might create. I'm afraid these things might occupy a lot of time and I can't say much about this because I simply don't know.

What are three key terms about you and your candidacy?

[Andreas]:

As I said, I like to work on standards, I’d like to make Debian try [to get it right so] that people don't get overworked, this third key point is be inviting to newcomers, to everybody who wants to come. Yeah, I also mentioned in my term this diversity issue, geographical and from gender point of view. This may be the three points I consider most important.

Preferred text editor?

[Andreas]:

Yeah, my preferred one? Ah, well, I have no preferred text editor. I'm using the Midnight Commander very frequently which has an internal editor which is convenient for small text. For other things, I usually use VI but I also use Emacs from time to time. So, no, I have not preferred text editor. Whatever works nicely for me.

What is the importance of the community in the Debian Project? How would like to see it evolving over the next few years?

[Andreas]:

Yeah, I think the community is extremely important. So, I was on a lot of DebConfs. I think it's not really 20 but 17 or 18 DebCons and I really enjoyed these events every year because I met so many friends and met so many interesting people that it's really enriching my life and those who I never met in person but have read interesting things and yeah, Debian community makes really a part of my life.

And how do you think it should evolve specifically?

[Andreas]:

Yeah, for instance, last year in Kochi, it became even clearer to me that the geographical diversity is a really strong point. Just discussing with some women from India who is afraid about not coming next year to Busan because there's a problem with Shanghai and so on. I'm not really sure how we can solve this but I think this is a problem at least I wish to tackle and yeah, this is an interesting point, the geographical diversity and I'm running the so-called mentoring of the month.

This is a small project to attract newcomers for the Debian Med team which has the focus on medical packages and I learned that we had always men applying for this and so I said, okay, I dropped the constraint of medical packages.

Any topic is fine, I teach you packaging but it must be someone who does not consider himself a man. I got only two applicants, no, actually, I got one applicant and one response which was kind of strange if I'm hunting for women or so.

I did not understand but I got one response and interestingly, it was for me one of the least expected counters. It was from Iran and I met a very nice woman, very open, very skilled and gifted and did a good job or have even lose contact today and maybe we need more actively approach groups that are underrepresented. I don't know if what's a good means which I did but at least I tried and so I try to think about these kind of things.

What part of Debian has made you smile? What part of the project has kept you going all through the years?

[Andreas]:

Well, the card game which is called Mao on the DebConf made me smile all the time. I admit I joined only two or three times even if I really love this kind of games but I was occupied by other stuff so this made me really smile. I also think the first online DebConf in 2020 made me smile because we had this kind of short video sequences and I tried to make a funny video sequence about every DebConf I attended before. This is really funny moments but yeah, it's not only smile but yeah.

One thing maybe it's totally unconnected to Debian but I learned personally something in Debian that we have a do-ocracy and you can do things which you think that are right if not going in between someone else, right? So respect everybody else but otherwise you can do so.

And in 2020 I also started to take trees which are growing widely in my garden and plant them into the woods because in our woods a lot of trees are dying and so I just do something because I can. I have the resource to do something, take the small tree and bring it into the woods because it does not harm anybody. I asked the forester if it is okay, yes, yes, okay. So everybody can do so but I think the idea to do something like this came also because of the free software idea. You have the resources, you have the computer, you can do something and you do something productive, right? And when thinking about this I think it was also my Debian work.

Meanwhile I have planted more than 3,000 trees so it's not a small number but yeah, I enjoy this.

What part of Debian would you have some criticisms for?

[Andreas]:

Yeah, it's basically the same as I said before. We need more standards to work together. I do not want to repeat this but this is what I think, yeah.

What field in Free Software generally do you think requires the most work to be put into it? What do you think is Debian's part in the field?

[Andreas]:

It's also in general, the thing is the fact that I'm maintaining packages which are usually as modern software is maintained in Git, which is fine but we have some software which is at Sourceport, we have software laying around somewhere, we have software where Debian somehow became Upstream because nobody is caring anymore and free software is very different in several things, ways and well, I in principle like freedom of choice which is the basic of all our work.

Sometimes this freedom goes in the way of productivity because everybody is free to re-implement. You asked me for the most favorite editor. In principle one really good working editor would be great to have and would work and we have maybe 500 in Debian or so, I don't know.

I could imagine if people would concentrate and say five instead of 500 editors, we could get more productive, right? But I know this will not happen, right? But I think this is one thing which goes in the way of making things smooth and productive and we could have more manpower to replace one person who's [having] children, doing some other stuff and can't continue working on something and maybe this is a problem I will not solve, definitely not, but which I see.

What do you think is Debian's part in the field?

[Andreas]:

Yeah, well, okay, we can bring together different Upstreams, so we are building some packages and have some general overview about similar things and can say, oh, you are doing this and some other person is doing more or less the same, do you want to join each other or so, but this is kind of a channel we have to our Upstreams which is probably not very successful.

It starts with code copies of some libraries which are changed a little bit, which is fine license-wise, but not so helpful for different things and so I've tried to convince those Upstreams to forward their patches to the original one, but for this and I think we could do some kind of, yeah, [find] someone who brings Upstream together or to make them stop their forking stuff, but it costs a lot of energy and we probably don't have this and it's also not realistic that we can really help with this problem.

Do you have any questions for me?

[Andreas]:

I enjoyed the interview, I enjoyed seeing you again after half a year or so. Yeah, actually I've seen you in the eating room or cheese and wine party or so, I do not remember we had to really talk together, but yeah, people around, yeah, for sure. Yeah.

Categories: FLOSS Project Planets

PyBites: Python F-String Codes I Use Every Day

Planet Python - Fri, 2024-04-05 12:15

A few examples that will save the day probably* 95% of time.

*I don’t have the actual data but seriously, I bet you’ll find those tips useful more often than not!

Introduction

This article was originally posted on Medium.

I use f-strings every day. The irony is I also every day end up searching the Web to find the correct format to use. Until one day I thought a better use of my time would be to create a cheat sheet of the most common formatting cases — AKA this article. It covers the following:

  • integers, floats, numbers and scientific notation
  • percentages %
  • dates
  • padding
  • adding +/- sign in front of a number

It’s important to note that the f-strings were first introduced in Python 3.6 (PEP 498 if you REALLY must know) so make sure to check the Python version first, if things don’t work for you.

The format

The most basic f-string format goes like this:

You can use this format to print numbers, texts, or even evaluate expressions.

author = "pawjast" year = 2022 print(f"Example 1: {author}") # string print(f"Example 2: {year}") # number print(f"Example 3: {2 + 2}") # expression

The output:

Example 1: pawjast Example 2: 2022 Example 3: 4

You might have noticed that the 2+2 expression in Example 3 got evaluated and 4 was printed.

You’ll get both, the name and the value if you add = sign to a variable.

text = "Data Science Blog" print(f"{text=}")

The output:

text='Data Science Blog'

Template below generalizes how you can add a specific format to a variable:

Next paragraphs shows examples of how to use it.

Recap on numbers

Last stop before going any further. I’ll be using different ways of writing numbers later in the article so let’s review the most common ones.

int_1 = 1 int_with_separator = 1_000 # `int` with 1,000 separator float_1 = 1.125 float_2 = 3.50 scientific_1 = 1.23e2 # 1.23 * 10^2 print(f"Example 1 - int: {int_1}") print(f"Example 2 - int with _ as thousands separator: {int_with_separator}") print(f"Example 3 - float: {float_1}") print(f"Example 4 - float with trailing zero: {float_2}") print(f"Example 5 - float in scientific notation: {scientific_1}")

The output:

Example 1 - int: 1 Example 2 - int with _ as thousands separator: 1000 Example 3 - float: 1.125 Example 4 - float with trailing zero: 3.5 Example 5 - float in scientific notation: 123.0

You can observe that:

  • floats had the trailing zeros truncated (Example 4)
  • scientific notation was printed as a regular float
  • the rest of the variables were printed “as is”
Floats

The float type is enforced by using code f. What you want to control in floats is the number of decimal places.

pi_val = 3.141592 print(f"Example 1: {pi_val:f}") print(f"Example 2: {pi_val:.0f}") print(f"Example 3: {pi_val:.1f}") print(f"Example 4: {pi_val:.3f}")

The output:

Example 1: 3.141592 Example 2: 3 Example 3: 3.1 Example 4: 3.142

Side note: f-strings are flexible enough to allow nesting.

float_val = 1.5 precision = 3 print(f"{float_val:.{precision}f}")

The output:

1.500 Percentage

Use code % to enforce percentage type. Percentage is still a float so you can still use .<whole_number> to control the precision.

val = 0.5 print(f"Example 1: {val:%}") print(f"Example 2: {val:.0%}")

The output:

Example 1: 50.000000% Example 2: 50%

More examples of controlling precision in %:

val = 1.255 print(f"Example 1: {val:.0%}") print(f"Example 2: {val:.1%}")

The output:

Example 1: 125% Example 2: 125.5% Scientific notation

If you want scientific notation to be printed as such (and not as a regular float) it can be enforced with e or E code.

val = 1.23e3 # 1.23 * 10^3 print(f"Example 1: {val:e}") print(f"Example 2: {val:E}")

The output:

1: 1.230000e+03 2: 1.230000E+03

No surprise the precision can be controlled in this case too.

val = 1.2345e3 print(f"{val:.2e}")

The output:

1.23e+03

You can even print a regular number in scientific notation.

val = 2022 print(f"{val:.3e}")

The output:

2.022e+03 Integers

Integers are enforced using code d.

val = 1 print(f"{val:d}")

The output:

1

Adding , to the code will print the thousands separator.

int_1 = 1000 int_2 = 1000_000_000 print(f"{int_1:,d}") print(f"{int_2:,d}")

The output:

1,000 1,000,000,000 Numbers

If the aim is to just print a number, you can use generic code — n.

val_int = 1 val_float = 1.234 val_scient = 4.567e2 print(f"{val_int =: n}") print(f"{val_float =: n}") print(f"{val_scient =: n}")

The output:

val_int = 1 val_float = 1.234 val_scient = 456.7

You can still use .<whole_number> format to control the precision.

Side note: in this case whole_number determines the total number of digits printed, not the number of decimal points! On top of that, n code will decide the best output format for a number.

val_float_1 = 1.234 val_float_2 = 20.234 val_float_3 = 123.456 print(f"{val_float_1 =: .2n}") # prints as truncated float print(f"{val_float_2 =: .2n}") # prints as int print(f"{val_float_3 =: .2n}") # prints as scientific notation

The output:

val_float_1 = 1.2 val_float_2 = 20 val_float_3 = 1.2e+02 Dates from datetime import date, datetime

Printing a date “as is” works exactly like printing any other variable.

day = date( year=2022, month=9, day=1 ) print(f"{day}")

The output:

2022-09-01

To recreate the format you will use the following codes:

  • %Y for year
  • %m for month
  • %d for day

With those codes you can e.g. create a new date format.

print(f"{day:%Y-%m-%d}") # default appearance print(f"{day:%Y/%m/%d}") # use `/` as separator

The output:

2022-09-01 2022/09/01

It’s also possible to print a month as a text:

  • %b — short version
  • %B — long version
print(f"{day:%Y %b %d}") print(f"{day:%Y %B %d}")

The output:

2022 Sep 01 2022 September 01

The same variable can be printed multiple times.

print(f"{day:%b or %B}?") print(f"{day:%Y %Y %Y}"

The output:

Sep or September? 2022 2022 2022

Reusing the same variable can be useful e.g. when you want to print the date and provide the day of the week as text (using code %A ).

print(f"{day:%Y %b %d (%A)}")

The outcome:

2022 Sep 01 (Thursday)

Last but not least, you can swap %Y for %y to get short version of the year.

print(f"{day:%y.%m.%d}")

The output:

22.09.01 Datetime

Let’s specify two datetime variables.

day_and_time = datetime( year=2022, month=9, day=1, hour=17, minute=30, second=45 ) now = datetime.now() print(f"{day_and_time}") print(f"{now}") # with mircoseconds

The output:

2022-09-01 17:30:45 2022-12-08 15:49:37.810347

Time format requires the following codes:

  • %H — hour
  • %M — minute
  • %S — second
  • %f — millisecond (1s = 1000 milliseconds)

Therefore, the default format would look like below.

print(f"{now:%Y-%m-%d %H:%M:%S.%f}")

The outcome:

2022-12-08 15:49:37.810347

f-string obviously creates a string (try this code to confirm it: type(f”now:%Y-%m-%d %H:%M%S.%f}”)). Therefore, if e.g. you are not happy with the number of decimal points for milliseconds, you can easily truncate them.

print(f"{now:%Y-%m-%d %H:%M:%S.%f}"[:22])

The output:

2022-12-08 15:49:37.81

In order to change the 24hr format to 12hr format, you will need to:

  • swap hour code from %H to %I
  • Optionally add %p at the end if you want to add AM/PM to the time
print(f"24hr: {day_and_time:%Y-%m-%d %H:%M:%S}") print(f"12hr: {day_and_time:%Y-%m-%d %I:%M:%S}") print(f"12hr with AM/PM: {day_and_time:%Y-%m-%d %I:%M:%S %p}")

The output:

24hr: 2022-09-01 17:30:45 12hr: 2022-09-01 05:30:45 12hr with AM/PM: 2022-09-01 05:30:45 PM

Few more useful date formats:

  • %j for day of the year
  • %W for week of the year (assuming Monday as first day of the week)
  • %U for week of the year (assuming Sunday as first day of the week
day = date( year=2018, month=9, day=17 ) print(f"The date: {day}") print(f"Day of the year: {day: %j}") print(f"Week of the year (Mon): {day: %W}") print(f"Week of the year (Sun): {day: %U}")

The outcome:

The date: 2018-09-17 Day of the year: 260 Week of the year (Mon): 38 Week of the year (Sun): 37 Padding

Padding with empty spaces.

val = 1 print(f"1: {val:1d}") print(f"2: {val:2d}") print(f"3: {val:3d}")

The output:

1: 1 2: 1 3: 1

Padding with zeros.

val = 1 print(f"1: {val:01d}") print(f"2: {val:02d}") print(f"3: {val:03d}")

The output:

1: 1 2: 01 3: 001

I usually use zero — padding with for loop to keep the text nicely aligned in the terminal.

for i in range(11): print(f"{i:02d}")

The output:

01 02 ... 09 10 Positive/negative sign

In some cases you will require to show a +/- sign next to a number.

positive = 1.23 negative = -1.23 print(f"1: {positive:+.2f} {negative:+.2f}") print(f"2: {positive:-.2f} {negative:-.2f}") print(f"3: {positive: .2f} {negative: .2f}")

The output:

1: +1.23 -1.23 2: 1.23 -1.23 3: 1.23 -1.23 Combining all things together # print variable with name, limit precision and thousands separator val = 11500.23456 print(f"{val = :,.3f}")

The output:

val = 11,500.235

We’re done .

Full code

 GitHub notebook

Connect with me

 Medium  Twitter / X  GitHub  Substack  LinkedIn

Resources

1⃣ https://docs.python.org/3/reference/lexical_analysis.html#f-strings

2⃣ https://docs.python.org/3/library/string.html#format-specification-mini-language

3⃣ https://strftime.org/

Categories: FLOSS Project Planets

Pages