Feeds

Dominique Dumont: New cme command to update Debian Standards-Version field

Planet Debian - Sat, 2024-12-07 12:52

Hi

While updating my Debian package, I often have to update a field from debian/control file.

This field is named Standards-Version and it declares which version of Debian policy the package complies to. When updating this field, one must follow the upgrading checklist.

That being said, I maintain a lot of similar package and I often have to update this Standards-Version field.

This field can be updated manually with cme fix dpkg (see Managing Debian packages with cme). But this command may make other changes and does not commit the result.

So I’ve created a new update-standards-version cme script that:

  • udpate Standards-Version field
  • commit the changed

For instance:

$ cme run update-standards-version Reading package lists... Done Building dependency tree... Done Reading state information... Done Connecting to api.ftp-master.debian.org to check 31 package versions. Please wait... Got info from api.ftp-master.debian.org for 31 packages. Warning in 'source Standards-Version': Current standards version is '4.7.0'. Please read https://www.debian.org/doc/debian-policy/upgrading-checklist.html for the changes that may be needed on your package to upgrade it from standard version '4.6.2' to '4.7.0'. Offending value: '4.6.2' Changes applied to dpkg-control configuration: - source Standards-Version: '4.6.2' -> '4.7.0' [master 552862c1] control: declare compliance with Debian policy 4.7.0 1 file changed, 1 insertion(+), 1 deletion(-)

Here’s the generated commit. Note that the generated log mentions the new policy version:

domi@ylum:~/private/debian-dev/perl-stuff/libconfig-model-perl$ git show commit 552862c1f24479b1c0c8c35a6289557f65e8ff3b (HEAD -> master) Author: Dominique Dumont <dod[at]debian.org> Date: Sat Dec 7 19:06:14 2024 +0100 control: declare compliance with Debian policy 4.7.0 diff --git a/debian/control b/debian/control index cdb41dc0..e888012e 100644 --- a/debian/control +++ b/debian/control @@ -48,7 +48,7 @@ Build-Depends-Indep: dh-sequence-bash-completion, libtext-levenshtein-damerau-perl, libyaml-tiny-perl, po-debconf -Standards-Version: 4.6.2 +Standards-Version: 4.7.0 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libconfig-model-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libconfig-model-perl.git Homepage: https://github.com/dod38fr/config-model/wiki

Notes:

  • this script can run only if there’s not pending change. Please commit or stash these changes before running this script.
  • this script requires:
    • cme >= 1.041
    • libconfig-model-perl >= 2.155
    • libconfig-model-dpkg-perl >= 3.006

I hope this will be useful to all my fellow Debian developers to reduce the boring parts of packaging activities.

All the best

Categories: FLOSS Project Planets

Freelock Blog: Remind customers of abandoned carts

Planet Drupal - Sat, 2024-12-07 10:00
Remind customers of abandoned carts Anonymous (not verified) Sat, 12/07/2024 - 07:00 Tags Analytics ECA Customer Service Drupal Planet

Sometimes a simple reminder can spur a sale. If you have repeat customers that log into your commerce site, you may be able to remind them if they did not complete a checkout.

Categories: FLOSS Project Planets

The Drop Times: DrupalCon Singapore 2024: Spotlight on Sponsors Driving Innovation and Community Growth

Planet Drupal - Sat, 2024-12-07 09:41
This is a chance to engage with leading developers, project managers, and decision-makers who are shaping Drupal's future. Beyond the exposure, sponsors gain valuable insights and opportunities to build lasting relationships within the community.
Categories: FLOSS Project Planets

Real Python: Linear Regression in Python

Planet Python - Sat, 2024-12-07 09:00

Linear regression is a foundational statistical tool for modeling the relationship between a dependent variable and one or more independent variables. It’s widely used in data science and machine learning to predict outcomes and understand relationships between variables. In Python, implementing linear regression can be straightforward with the help of third-party libraries such as scikit-learn and statsmodels.

By the end of this tutorial, you’ll understand that:

  • Linear regression is a statistical method for modeling the relationship between a dependent variable and one or more independent variables by fitting a linear equation.
  • Implementing linear regression in Python involves using libraries like scikit-learn and statsmodels to fit models and make predictions.
  • The formula for linear regression is 𝑦 = 𝛽₀ + 𝛽₁𝑥₁ + ⋯ + 𝛽ᵣ𝑥ᵣ + 𝜀, representing the linear relationship between variables.
  • Simple linear regression involves one independent variable, whereas multiple linear regression involves two or more.
  • The scikit-learn library provides a convenient and efficient interface for performing linear regression in Python.

To implement linear regression in Python, you typically follow a five-step process: import necessary packages, provide and transform data, create and fit a regression model, evaluate the results, and make predictions. This approach allows you to perform both simple and multiple linear regressions, as well as polynomial regression, using Python’s robust ecosystem of scientific libraries.

Free Bonus: Click here to get access to a free NumPy Resources Guide that points you to the best tutorials, videos, and books for improving your NumPy skills.

Take the Quiz: Test your knowledge with our interactive “Linear Regression in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Linear Regression in Python

In this quiz, you'll test your knowledge of linear regression in Python. Linear regression is one of the fundamental statistical and machine learning techniques, and Python is a popular choice for machine learning.

Regression

Regression analysis is one of the most important fields in statistics and machine learning. There are many regression methods available. Linear regression is one of them.

What Is Regression?

Regression searches for relationships among variables. For example, you can observe several employees of some company and try to understand how their salaries depend on their features, such as experience, education level, role, city of employment, and so on.

This is a regression problem where data related to each employee represents one observation. The presumption is that the experience, education, role, and city are the independent features, while the salary depends on them.

Similarly, you can try to establish the mathematical dependence of housing prices on area, number of bedrooms, distance to the city center, and so on.

Generally, in regression analysis, you consider some phenomenon of interest and have a number of observations. Each observation has two or more features. Following the assumption that at least one of the features depends on the others, you try to establish a relation among them.

In other words, you need to find a function that maps some features or variables to others sufficiently well.

The dependent features are called the dependent variables, outputs, or responses. The independent features are called the independent variables, inputs, regressors, or predictors.

Regression problems usually have one continuous and unbounded dependent variable. The inputs, however, can be continuous, discrete, or even categorical data such as gender, nationality, or brand.

It’s a common practice to denote the outputs with 𝑦 and the inputs with 𝑥. If there are two or more independent variables, then they can be represented as the vector 𝐱 = (𝑥₁, …, 𝑥ᵣ), where 𝑟 is the number of inputs.

When Do You Need Regression?

Typically, you need regression to answer whether and how some phenomenon influences the other or how several variables are related. For example, you can use it to determine if and to what extent experience or gender impacts salaries.

Regression is also useful when you want to forecast a response using a new set of predictors. For example, you could try to predict electricity consumption of a household for the next hour given the outdoor temperature, time of day, and number of residents in that household.

Regression is used in many different fields, including economics, computer science, and the social sciences. Its importance rises every day with the availability of large amounts of data and increased awareness of the practical value of data.

Linear Regression

Linear regression is probably one of the most important and widely used regression techniques. It’s among the simplest regression methods. One of its main advantages is the ease of interpreting results.

Problem Formulation

When implementing linear regression of some dependent variable 𝑦 on the set of independent variables 𝐱 = (𝑥₁, …, 𝑥ᵣ), where 𝑟 is the number of predictors, you assume a linear relationship between 𝑦 and 𝐱: 𝑦 = 𝛽₀ + 𝛽₁𝑥₁ + ⋯ + 𝛽ᵣ𝑥ᵣ + 𝜀. This equation is the regression equation. 𝛽₀, 𝛽₁, …, 𝛽ᵣ are the regression coefficients, and 𝜀 is the random error.

Read the full article at https://realpython.com/linear-regression-in-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 ]

Categories: FLOSS Project Planets

Real Python: Socket Programming in Python (Guide)

Planet Python - Sat, 2024-12-07 09:00

Socket programming is essential for network communication, enabling data exchange across different devices. In Python, sockets allow for inter-process communication (IPC) over networks. This tutorial provides a comprehensive guide on creating socket servers and clients, handling multiple connections, and managing errors in Python’s socket module.

By the end of this tutorial, you’ll understand that:

  • A socket in Python is an endpoint for sending or receiving data across a network using the socket API.
  • Socket programming in Python involves using sockets to establish communication between a server and clients over a network.
  • A simple echo server in Python can be created using sockets to listen for client connections and echo back received messages.
  • Handling multiple clients with Python sockets can be achieved using non-blocking sockets and the selectors module for concurrent connections.
  • Connection errors in socket programs in Python can be managed by implementing error handling and using exceptions like OSError.

Along the way, you’ll learn about the main functions and methods in Python’s socket module that let you write your own client-server applications based on TCP sockets. You’ll learn how to reliably send messages and data between endpoints and handle multiple connections simultaneously.

Networking and sockets are large subjects. Literal volumes have been written about them. If you’re new to sockets or networking, it’s completely normal if you feel overwhelmed with all of the terms and pieces. To get the most out of this tutorial, it’s best to download the source code and have it on hand for reference while reading:

Get Your Code: Click here to get the free sample code you’ll use to learn about socket programming in Python.

Take the Quiz: Test your knowledge with our interactive “Socket Programming in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Socket Programming in Python

In this quiz, you'll test your understanding of Python sockets. With this knowledge, you'll be able to create your own client-server applications, handle multiple connections simultaneously, and send messages and data between endpoints.

Historical Background

Sockets have a long history. Their use originated with ARPANET in 1971 and later became an API in the Berkeley Software Distribution (BSD) operating system released in 1983 called Berkeley sockets.

When the Internet took off in the 1990s with the World Wide Web, so did network programming. Web servers and browsers weren’t the only applications taking advantage of newly connected networks and using sockets. Client-server applications of all types and sizes came into widespread use.

Today, although the underlying protocols used by the socket API have evolved over the years, and new ones have developed, the low-level API has remained the same.

The most common type of socket applications are client-server applications, where one side acts as the server and waits for connections from clients. This is the type of application that you’ll be creating in this tutorial. More specifically, you’ll focus on the socket API for Internet sockets, sometimes called Berkeley or BSD sockets. There are also Unix domain sockets, which can only be used to communicate between processes on the same host.

Python Socket API Overview

Python’s socket module provides an interface to the Berkeley sockets API. This is the module that you’ll use in this tutorial.

The primary socket API functions and methods in this module are:

  • socket()
  • .bind()
  • .listen()
  • .accept()
  • .connect()
  • .connect_ex()
  • .send()
  • .recv()
  • .close()

Python provides a convenient and consistent API that maps directly to system calls, their C counterparts. In the next section, you’ll learn how these are used together.

As part of its standard library, Python also has classes that make using these low-level socket functions easier. Although it’s not covered in this tutorial, you can check out the socketserver module, a framework for network servers. There are also many modules available that implement higher-level Internet protocols like HTTP and SMTP. For an overview, see Internet Protocols and Support.

TCP Sockets

You’re going to create a socket object using socket.socket(), specifying the socket type as socket.SOCK_STREAM. When you do that, the default protocol that’s used is the Transmission Control Protocol (TCP). This is a good default and probably what you want.

Why should you use TCP? The Transmission Control Protocol (TCP):

  • Is reliable: Packets dropped in the network are detected and retransmitted by the sender.
  • Has in-order data delivery: Data is read by your application in the order it was written by the sender.

In contrast, User Datagram Protocol (UDP) sockets created with socket.SOCK_DGRAM aren’t reliable, and data read by the receiver can be out-of-order from the sender’s writes.

Why is this important? Networks are a best-effort delivery system. There’s no guarantee that your data will reach its destination or that you’ll receive what’s been sent to you.

Network devices, such as routers and switches, have finite bandwidth available and come with their own inherent system limitations. They have CPUs, memory, buses, and interface packet buffers, just like your clients and servers. TCP relieves you from having to worry about packet loss, out-of-order data arrival, and other pitfalls that invariably happen when you’re communicating across a network.

Read the full article at https://realpython.com/python-sockets/ »

[ 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 ]

Categories: FLOSS Project Planets

Real Python: How to Round Numbers in Python

Planet Python - Sat, 2024-12-07 09:00

Rounding numbers in Python is an essential task, especially when dealing with data precision. Python’s built-in round() function uses the rounding half to even strategy, which rounds numbers like 2.5 to 2 and 3.5 to 4. This method helps minimize rounding bias in datasets. To round numbers to specific decimal places, you can use the round() function with a second argument specifying the number of decimals.

For more advanced rounding strategies, you can explore Python’s decimal module or use NumPy and pandas for data science applications. NumPy arrays and pandas DataFrames offer methods for rounding numbers efficiently. In NumPy, you can use functions like np.round(), np.ceil(), np.floor(), and np.trunc() to apply different rounding strategies. For pandas, the df.round() method allows rounding of entire DataFrames or specific columns.

By the end of this tutorial, you’ll understand that:

  • Python uses the rounding half to even strategy, where ties round to the nearest even number.
  • Python’s default rounding strategy minimizes rounding bias in large datasets.
  • You can round numbers to specific decimal places using Python’s round() function with a second argument.
  • Different rounding strategies can be applied using Python’s decimal module or custom functions for precision control.
  • NumPy and pandas provide methods for rounding numbers in arrays and DataFrames, offering flexibility in data manipulation.

You won’t get a treatise on numeric precision in computing, although you’ll touch briefly on the subject. Only a familiarity with the fundamentals of Python is necessary, and the math should feel familiar if you’ve had high school algebra.

You’ll start by looking at Python’s built-in rounding mechanism.

Take the Quiz: Test your knowledge with our interactive “Rounding Numbers in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Rounding Numbers in Python

Test your knowledge of rounding numbers in Python.

Get Your Code: Click here to download the free sample code you’ll use to learn about rounding numbers in Python.

Python’s Built-in round() Function

Python has a built-in round() function that takes two numeric arguments, n and ndigits, and returns the number n rounded to ndigits. The ndigits argument defaults to zero, so leaving it out results in a number rounded to an integer. As you’ll see, round() may not work quite as you expect.

The way most people are taught to round a number goes something like this:

  • Round the number n to p decimal places by first shifting the decimal point in n by p places. To do that, multiply n by 10ᵖ (10 raised to the p power) to get a new number, m.

  • Then look at the digit d in the first decimal place of m. If d is less than 5, round m down to the nearest integer. Otherwise, round m up.

  • Finally, shift the decimal point back p places by dividing m by 10ᵖ.

It’s an algorithm! For example, the number 2.5 rounded to the nearest whole number is 3. The number 1.64 rounded to one decimal place is 1.6.

Now open up an interpreter session and round 2.5 to the nearest whole number using Python’s built-in round() function:

Python >>> round(2.5) 2 Copied!

Gasp!

Check out how round() handles the number 1.5:

Python >>> round(1.5) 2 Copied!

So, round() rounds 1.5 up to 2, and 2.5 down to 2!

Before you go raising an issue on the Python bug tracker, rest assured you that round(2.5) is supposed to return 2. There’s a good reason why round() behaves the way it does.

In this tutorial, you’ll learn that there are more ways to round a number than you might expect, each with unique advantages and disadvantages. round() behaves according to a particular rounding strategy—which may or may not be the one you need for a given situation.

You might be wondering, Can the way I round numbers really have that much of an impact? Next up, take a look at just how extreme the effects of rounding can be.

How Much Impact Can Rounding Have?

Suppose you have an incredibly lucky day and find $100 on the ground. Rather than spending all your money at once, you decide to play it smart and invest your money by buying some shares of different stocks.

The value of a stock depends on supply and demand. The more people there are who want to buy a stock, the more value that stock has, and vice versa. In high-volume stock markets, the value of a particular stock can fluctuate on a second-by-second basis.

Read the full article at https://realpython.com/python-rounding/ »

[ 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 ]

Categories: FLOSS Project Planets

Real Python: Python GUI Programming With Tkinter

Planet Python - Sat, 2024-12-07 09:00

Tkinter is Python’s standard GUI framework, making it convenient for developing graphical user interfaces. As a cross-platform library, Tkinter ensures your applications appear native across Windows, macOS, and Linux. Despite criticisms of its outdated appearance, Tkinter remains a practical choice for quickly creating functional and cross-platform GUI applications.

By the end of this tutorial, you’ll understand that:

  • GUI refers to graphical user interfaces, and Tkinter is Python’s built-in library for creating them.
  • Tkinter is included with most Python installations, so separate installation is often unnecessary.
  • Tkinter is still a relevant choice for building simple, cross-platform GUI applications.
  • Widgets in a Tkinter application can be arranged using geometry managers like .pack(), .place(), and .grid().
  • Interactive GUI applications with Tkinter are created by binding events, such as button clicks, to Python functions.

You’ll cover getting started with Tkinter, managing widgets, and creating interactive applications. Once you’ve mastered these skills by working through the exercises at the end of each section, you’ll tie everything together by building two applications. The first is a temperature converter, and the second is a text editor. It’s time to dive right in and learn how to build an application with Tkinter!

Note: This tutorial is adapted from the chapter “Graphical User Interfaces” of Python Basics: A Practical Introduction to Python 3.

The book uses Python’s built-in IDLE editor to create and edit Python files and interact with the Python shell. In this tutorial, references to IDLE have been removed in favor of more general language.

The bulk of the material in this tutorial has been left unchanged, and you should have no problems running the example code from the editor and environment of your choice.

Free Bonus: 5 Thoughts On Python Mastery, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.

Take the Quiz: Test your knowledge with our interactive “Python GUI Programming With Tkinter” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

Python GUI Programming With Tkinter

In this quiz, you'll test your understanding of Python GUI Programming With Tkinter, the de facto Python GUI framework. Check your knowledge of GUI programming concepts such as widgets, geometry managers, and event handlers.

Building Your First Python GUI Application With Tkinter

The foundational element of a Tkinter GUI is the window. Windows are the containers in which all other GUI elements live. These other GUI elements, such as text boxes, labels, and buttons, are known as widgets. Widgets are contained inside of windows.

First, create a window that contains a single widget. Start up a new Python shell session and follow along!

Note: The code examples in this tutorial have all been tested on Windows, macOS, and Ubuntu Linux 20.04 with Python version 3.10.

If you’ve installed Python with the official installers available for Windows and macOS from python.org, then you should have no problem running the sample code. You can safely skip the rest of this note and continue with the tutorial!

If you haven’t installed Python with the official installers, or there’s no official distribution for your system, then here are some tips for getting up and going.

Python on macOS with Homebrew:

The Python distribution for macOS available on Homebrew doesn’t come bundled with the Tcl/Tk dependency required by Tkinter. The default system version is used instead. This version may be outdated and prevent you from importing the Tkinter module. To avoid this problem, use the official macOS installer.

Ubuntu Linux 20.04:

To conserve memory space, the default version of the Python interpreter that comes pre-installed on Ubuntu Linux 20.04 has no support for Tkinter. However, if you want to continue using the Python interpreter bundled with your operating system, then install the following package:

Shell $ sudo apt-get install python3-tk Copied!

This installs the Python GUI Tkinter module.

Other Linux Flavors:

If you’re unable to get a working Python installation on your flavor of Linux, then you can build Python with the correct version of Tcl/Tk from the source code. For a step-by-step walk-through of this process, check out the Python 3 Installation & Setup Guide. You may also try using pyenv to manage multiple Python versions.

With your Python shell open, the first thing you need to do is import the Python GUI Tkinter module:

Python >>> import tkinter as tk Copied!

A window is an instance of Tkinter’s Tk class. Go ahead and create a new window and assign it to the variable window:

Python >>> window = tk.Tk() Copied!

When you execute the above code, a new window pops up on your screen. How it looks depends on your operating system:

Throughout the rest of this tutorial, you’ll see Windows screenshots.

Adding a Widget

Now that you have a window, you can add a widget. Use the tk.Label class to add some text to a window. Create a Label widget with the text "Hello, Tkinter" and assign it to a variable called greeting:

Python >>> greeting = tk.Label(text="Hello, Tkinter") Copied!

The window you created earlier doesn’t change. You just created a Label widget, but you haven’t added it to the window yet. There are several ways to add widgets to a window. Right now, you can use the Label widget’s .pack() method:

Python >>> greeting.pack() Copied!

The window now looks like this:

Read the full article at https://realpython.com/python-gui-tkinter/ »

[ 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 ]

Categories: FLOSS Project Planets

Real Python: When to Use a List Comprehension in Python

Planet Python - Sat, 2024-12-07 09:00

List comprehensions in Python provide a concise way to create lists by embedding a loop and optional conditional logic in a single line. You use a list comprehension to transform and filter elements from an iterable efficiently. It allows you to replace complex loops and map() functions with more readable and often faster expressions. By understanding list comprehensions, you can optimize your code for better performance and clarity.

You can add conditional logic to a list comprehension in Python by appending an if statement to the end of the expression. This allows you to filter elements based on a condition, effectively replacing the need for filter() in many cases. Additionally, you can use conditional expressions at the beginning to choose between different outcomes, enhancing the versatility of your list comprehensions.

By the end of this tutorial, you’ll understand that:

  • A list comprehension in Python is a tool for creating lists by iterating over an iterable and optionally applying a condition.
  • You should use list comprehensions instead of loops when you want concise, readable code that performs transformations or filtering.
  • You add conditional logic to a list comprehension by including an if statement within the comprehension.
  • A list comprehension can be faster than a for loop because it’s optimized for performance by Python’s internal mechanisms.
  • A Python list comprehension is not lazy—it generates and stores the entire list in memory eagerly.
  • The difference between list comprehensions and map() is that the former creates a list, while the latter returns a map object, which is iterable.
  • To optimize performance with list comprehensions, use them for small to medium-sized lists and profile different approaches to choose the fastest one.

In this tutorial, you’ll explore how to leverage list comprehensions to simplify your code. You’ll also gain an understanding of the trade-offs that come with using them so that you can determine when other approaches are preferable.

Get Your Code: Click here to download the free code that shows you how and when to use list comprehensions in Python.

Take the Quiz: Test your knowledge with our interactive “When to Use a List Comprehension in Python” quiz. You’ll receive a score upon completion to help you track your learning progress:

Interactive Quiz

When to Use a List Comprehension in Python

In this quiz, you'll test your understanding of Python list comprehensions. You'll revisit how to rewrite loops as list comprehensions, how to choose between comprehensions and loops, and how to use conditional logic in your comprehensions.

Transforming Lists in Python

There are a few different ways to create and add items to a lists in Python. In this section, you’ll explore for loops and the map() function to perform these tasks. Then, you’ll move on to learn about how to use list comprehensions and when list comprehensions can benefit your Python program.

Use for Loops

The most common type of loop is the for loop. You can use a for loop to create a list of elements in three steps:

  1. Instantiate an empty list.
  2. Loop over an iterable or range of elements.
  3. Append each element to the end of the list.

If you want to create a list containing the first ten perfect squares, then you can complete these steps in three lines of code:

Python >>> squares = [] >>> for number in range(10): ... squares.append(number * number) ... >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] Copied!

Here, you instantiate an empty list, squares. Then, you use a for loop to iterate over range(10). Finally, you multiply each number by itself and append the result to the end of the list.

Work With map Objects

For an alternative approach that’s based in functional programming, you can use map(). You pass in a function and an iterable, and map() will create an object. This object contains the result that you’d get from running each iterable element through the supplied function.

As an example, consider a situation in which you need to calculate the price after tax for a list of transactions:

Python >>> prices = [1.09, 23.56, 57.84, 4.56, 6.78] >>> TAX_RATE = .08 >>> def get_price_with_tax(price): ... return price * (1 + TAX_RATE) ... >>> final_prices = map(get_price_with_tax, prices) >>> final_prices <map object at 0x7f34da341f90> >>> list(final_prices) [1.1772000000000002, 25.4448, 62.467200000000005, 4.9248, 7.322400000000001] Copied!

Here, you have an iterable, prices, and a function, get_price_with_tax(). You pass both of these arguments to map() and store the resulting map object in final_prices. Finally, you convert final_prices into a list using list().

Leverage List Comprehensions

List comprehensions are a third way of making or transforming lists. With this elegant approach, you could rewrite the for loop from the first example in just a single line of code:

Python >>> squares = [number * number for number in range(10)] >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] Copied!

Rather than creating an empty list and adding each element to the end, you simply define the list and its contents at the same time by following this format:

Python Syntax new_list = [expression for member in iterable] Copied! Read the full article at https://realpython.com/list-comprehension-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 ]

Categories: FLOSS Project Planets

The Drop Times: Meet the Speakers: DrupalCon Singapore 2024 Part III

Planet Drupal - Sat, 2024-12-07 07:33
The excitement is palpable as DrupalCon Singapore 2024 kicks off tomorrow! In the final episode of our "Meet the Speakers" series, discover how Owen Lansbury of PreviousNext is redefining profitability through open-source business models, and learn from Aastha Shrivastava of QED42 as she spotlights Drupal’s role as a Digital Public Good. Get ready for three action-packed days of innovation, insights, and community from December 9-11, 2024. This is the moment the APAC Drupal community has been waiting for – don’t miss it!
Categories: FLOSS Project Planets

LostCarPark Drupal Blog: Drupal Advent Calendar day 7 - Base Recipe

Planet Drupal - Sat, 2024-12-07 04:00
Drupal Advent Calendar day 7 - Base Recipe james Sat, 12/07/2024 - 09:00

Today we are looking at one of the central elements of Starshot, but also one of the easiest to overlook.

Drupal CMS will come preinstalled with a set of base modules and themes, as the basis on which other recipes will be built. The base theme track is responsible for this. Not only does this provide essential functionality to make a new Drupal site much more usable, it also provides an important baseline for the other tracks to build upon.

Some of the functionality either already implemented, or planned past Drupal CMS 1.0, is listed below.

Pathauto is now installed by default. This is a small…

Tags
Categories: FLOSS Project Planets

Russ Allbery: Review: Dark Minds

Planet Debian - Sat, 2024-12-07 00:22

Review: Dark Minds, by Michelle Diener

Series: Class 5 #3 Publisher: Eclipse Copyright: 2016 ISBN: 0-6454658-5-2 Format: Kindle Pages: 328

Dark Minds is the third book in the self-published Class 5 science-fiction romance series. It is a sequel to Dark Deeds and should not be read out of order, but as with the other books of the series, it follows new protagonists.

Imogen, like another Earth woman before her, was kidnapped by a Class 5 for experimentation by the Tecran. She was subsequently transferred to a research facility and has been held in cages and secret military bases for over three months. As the story opens, she had been imprisoned in a Tecran transport for a couple of weeks when the transport is taken by the Krik who kill all of the Tecran crew. Next stop: another Class 5.

That same Class 5 is where the Krik are taking Camlar Kalor and his team. Cam is a Grih investigator from the United Council, sent to look into reports of a second Earth woman rescued from a Garmman ship. (The series reader will recognize this as the plot of Dark Deeds.) Now he's trapped with the crews of a bunch of other random ships in the cargo hold of a Class 5 with Krik instead of Tecran roaming the halls, apparently at the behest of the ship's banned AI, and a mysterious third Earth woman already appears to be befriending it.

Imogen is the woman Fiona saw signs of in Dark Deeds. She's had a rougher time than the protagonists of the previous two books in this series, and she's been dropped into a less stable situation. The Class 5 she's brought to at the start of the story is far more suspicious (with quite a lot of cause) and somewhat more hostile than the AIs we've encountered previously. The rest of the story formula is roughly the same, though: hunky Grih officer with a personality completely indistinguishable from the hunky Grih officers in the previous two books, an AI with a sketchy concept of morality that desperately needs an ally, the Grih obsession with singing, the eventual discovery of useful armor and weaponry that Imogen can use to surprise people, and more political maneuvering over the Sentient Beings Agreement.

This entry in the series mostly abandons the Grih shock and horror at how badly the Earth women have been treated. This makes sense, given how dangerous Earth women have proven over the course of this series, and I like that Diener is changing the political dynamics as the story develops. I do sometimes miss that appalled anger of Dark Horse, but Dark Minds focuses more on the politics and corridor fighting of a tense multi-sided stand-off.

I found the action more gripping in Dark Minds than in Dark Deeds, and I liked Imogen more as a character than Fiona. She doesn't have the delightfully calm competence of Rose from Dark Horse, but she's a bit more hardened, a bit more canny, and is better at taking control of situations. I also like that Diener avoids simplistically pairing Earth women off with Class 5s. The series plot is progressing faster than I had expected, and that gives this book a somewhat different shape than the previous ones.

Cam is probably the least interesting of the men in this series so far and appears to exist solely to take up the man-shaped hole in the plot. This is not a great series for gender roles; thankfully, the romance is a small part of the plot and largely ignorable. The story is about the women and the AIs, and all of the women and most of the AIs of the previous books make an appearance. It's clear they're forming an alliance whether the Grih like it or not, and that part of the story was very satisfying.

Up to this book, this series had been all feel-good happy endings. I will risk the small spoiler and warn that this is not true to the same degree here, so you may not want to read this one if you want something entirely fluffy, light, and positive (inasmuch as a series involving off-screen experimentation on humans can be fluffy, light, and positive). That caught me by surprise in a way I didn't entirely like, and I wish Diener had stuck with the entirely positive tone.

Other than that, though, this was fun, light, readable entertainment. It's not going to win any literary awards, it's formulaic, the male protagonist comes from central casting, and the emphasis by paragraph break is still a bit grating in places, but I will probably pick up the next book when I'm in the mood for something light. Dark Minds is an improvement over book two, which bodes well for the rest of the series.

Followed by Dark Matters.

Rating: 7 out of 10

Categories: FLOSS Project Planets

This Week in Plasma: Oodles of features!

Planet KDE - Fri, 2024-12-06 23:00

I promised new features soon, and here they are! There are plenty of positive UI changes too. Hopefully what this week's post lacks in quantity will be made up by depth, because these are some nice changes that have been in development for quite some time. Have a look:

Notable New Features

It's now possible to clone a panel! (Niccolò Venerandi, 6.3.0. Link)

KWin's Custom Tiling system now remembers tile arrangement on a per-virtual-desktop basis. (Marco Martin, 6.3.0. Link)

You can now set keyboard shortcuts to move windows between Custom Tiling (as opposed to Quick Tiling) tile zones based on directionality. No default shortcuts were set up for now because all the obvious Modifier+Arrow combinations were already taken. This is an avenue to ponder further in the future. (Akseli Lahtinen, 6.3.0. Link)

It's now possible to limit the upper and lower ranges for tablet pen pressure, not just the shape of the pressure curve. (Joshua Goins, 6.3.0. Link)

Notable UI Improvements

Categories in Kickoff no longer automatically switch on hover by default; they have to be clicked like all other list items elsewhere. This fixes a host of issues related to unexpected category switching and freezes when moving the pointer rapidly over categories. Those who preferred switch-on-hover can turn it back on if they like. (Noah Davis, 6.3.0. Link)

The way Quick Tiling (i.e. with Meta+Arrow keys) works has been slightly changed; now when trying to tile a window in a direction it can't be tiled in anymore because it has hit a screen edge with nothing beyond it, it will simply sit there, rather than un-tiling and teleporting to a potentially unexpected place. (Vlad Zahorodnii, 6.3.0. Link)

System Settings' Display & Monitor page now shows a slider for normal/SDR brightness for each screen, just in case you expected to find it there rather than in the System Tray's Brightness and Color widget. (Xaver Hugl, 6.3.0. Link)

When you hold down Alt+Tab to open the window switcher and then keep those keys held down, the selection highlight will now go all the way to the end, but will no longer hilariously wrap around infinitely until you release the keys again. (Ismael Asensio, 6.3.0. Link)

The active virtual desktop is now remembered per activity. (Xaver Hugl, 6.3.0. Link)

Notable Bug Fixes

Fixed a bug that could cause placeholder and typed text to overlap in KRunner's search field under certain circumstances. (Jack Xu, 6.2.5. Link)

Metadata displayed for Bing picture of the day wallpapers is now displayed correctly. (George Travelbacon, 6.2.5. Link)

When you copy images from Plasma notifications, they can now be pasted into sandboxed apps. (Alessandro Astone, 6.2.5. Link)

After using an application that goes through the input capture portal (e.g. Input Leap) and it quits unexpectedly, you now regain full control of your pointer and keyboard immediately. (David Redondo, 6.2.5 Link)

Keyboard navigation between a filtered subset of windows in the Overview effect now works as you expect it to. (Niccolò Venerandi, 6.3.0. Link)

When you delete a panel but haven't yet dismissed the option to unto this, the deleted panel no longer inappropriately and surprisingly responds to any keyboard shortcuts that toggle any of their widgets. (Niccolò Venerandi, 6.3.0. Link)

Other bug information of note:

Notable in Performance & Technical

Slightly increased the performance of every app and window that uses KWindowStateSaver. (David Edmundson, Frameworks 6.9, Link)

How You Can Help

KDE has become important in the world, and your time and contributions have helped us get there. As we grow, we need your support to keep KDE sustainable.

Thankfully, thousands of you have stepped up in the past week to do just that financially, donating a record-breaking amount of money to KDE e.V., which is just incredible, awe-inspiring even.

So that's a great way to help out. But if you've got more time than money or want to make a difference more directly, then you can help KDE by becoming an active community member and getting involved somehow. Each contributor makes a huge difference in KDE — you are not a number or a cog in a machine!

You don’t have to be a programmer, either. Many other opportunities exist:

To get a new Plasma feature or a bugfix mentioned here, feel free to push a commit to the relevant merge request on invent.kde.org.

Categories: FLOSS Project Planets

Louis-Philippe Véronneau: lintian.debian.org: Episode IV – A New Hope

Planet Debian - Fri, 2024-12-06 20:45

After weeks – dare I say months – of work, it is finally done. lintian.debian.org is back online!

Many, many thanks to everyone who worked hard to make this possible:

  • Thanks to Nicolas Peugnet, the author of lintian-ssg, who handed us this custom static site generator on a silver platter. I'm happy I didn't have to code this myself :)
  • Thanks to Otto Kekäläinen, maintainer of the lintian-ssg package in Debian, who worked in tandem with Nicolas to iron out problems.
  • Thanks to Philipp Kern, who did the work on the DSA side to put the website back online.

All in all, I did very little (mostly coordinating these fine folks) and they should get the credit for this very useful service being back.

Categories: FLOSS Project Planets

KPhotoAlbum 6.0.0 released

Planet KDE - Fri, 2024-12-06 19:00

This time, it’s a short one: We ported KPhotoAlbum to Qt6/KF6. That’s it ;-)

The port itself has been done by Johannes and me, additional commits have been contributed by Randall Rude and Fabian Würfl. Thanks for working on KPA with us!

One thing that’s worth mentioning is: For the map/geodata functionality, we need Marble. The Qt5/KF5 version of Marble can’t be co-installed with the Qt6/KF6 version, and this one is not released yet. But Marble 24.12.0 (which will be the first official Qt6/KF6 release) will be released in a few days. So just wait until it's out before upgrading to KPA 6, to not lose the map parts.

Maybe, the Qt6/KF6 version contains some regressions. The codebase is quite well advanced in years in some parts, and we had to mess with quite some legacy issues to make the whole thing fit for Qt6/KF6. So if you notice anything, please file a respective bug report and/or contact us via our mailing list or Matrix channel (cf. User support → Communication). Thanks for your participation (hopefully, it won’t be necessary too much).

Have a lot of fun with KPhotoAlbum 6 :-)

— Tobias

Categories: FLOSS Project Planets

Plasma Wayland Protocols 1.15.0

Planet KDE - Fri, 2024-12-06 19:00

Plasma Wayland Protocols 1.15.0 is now available for packaging. It is needed for the forthcoming KDE Frameworks.

URL: https://download.kde.org/stable/plasma-wayland-protocols/
SHA256: e5aedfe7c0b2443aa67882b4792d08814570e00dd82f719a35c922a0993f621e Signed by: E0A3EB202F8E57528E13E72FD7574483BB57B18D Jonathan Riddell jr@jriddell.org

Full changelog:

  • Add a request to create a virtual output stream with description
  • Add alpine CI
  • Add modifier information to keystate
  • gitignore: use same as KWin
  • Add a destructor to appmenu manager
  • Add protocol tests
  • Add CI for static builds on Linux
Categories: FLOSS Project Planets

Bálint Réczey: Firebuild 0.8.3 is out with 100+ fixes and experimental macOS support!

Planet Debian - Fri, 2024-12-06 16:53

The new Firebuild release contains plenty of small fixes and a few notable improvements.

Experimental macOS support

The most frequently asked question from people getting to know Firebuild was if it worked on their Mac and the answer sadly used to be that well, it did, but only in a Linux VM. This was far from what they were looking for. 🙁

Linux and macOS have common UNIX roots, but porting Firebuild to macOS included bigger challenges, like ensuring that dyld(1), macOS’s dynamic loader initializes the preloaded interceptor library early enough to catch all interesting calls, and avoid using anything that uses malloc() or thread local variables which are not yet set up then.

Preloading libraries on Linux is really easy, running LD_PRELOAD=my_lib.so ls just works if the library exports the symbols to be interposed, while macOS employs multiple lines of defense to prevent applications from using unknown libraries. Firebuild’s guide for making DYLD_INSERT_LIBRARIES honored on Macs can be helpful with other projects as well that rely on injecting libraries.

Since GitHub’s Arm64 macOS runners don’t allow intercepting binaries with arm64e ABI yet, Firebuild’s Apple Silicon tests are run at Bitrise, who are proud to be first to provide the latest Xcode stacks and were also quick to make the needed changes to their infrastructure to support Firebuild (thanks! ).

Firebuild on macOS can already accelerate simple projects and rebuild itself with Xcode. Since Xcode introduces a lot of nondeterminism to the build, Firebuild can’t shine in acceleration with Xcode yet, but can provide nice reports to show which part of the build is the most time consuming and how each sub-command is called.

If you would like to try Firebuild on macOS please compile it from the GitHub repository for now. Precompiled binaries will be distributed on the Mac App Store and via CI providers. Contact us to get notified when those channels become available.

Dealing with the ‘Epochalypse’

Glibc’s API provides many functions with time parameters and some of those functions are intercepted by Firebuild. Time parameters used to be passed as 32-bit values on 32-bit systems, preventing them to accurately represent timestamps after year 2038, which is known as the Y2038 problem or the Epochalypse.

To deal with the problem glibc 2.34 started providing new function symbol variants with 64-bit time parameters, e.g clock_gettime64() in addition to clock_gettime(). The new 64-bit variants are used when compiling consumers of the API with _TIME_BITS=64 defined.

Processes intercepted by Firebuild may have been compiled with or without _TIME_BITS=64, thus libfirebuild now provides both variants on affected systems running glibc >= 34 to work safely with binaries using 64-bit and 32-bit time representation.

Many Linux distributions already stopped supporting 32-bit architectures, but Debian and Ubuntu still supports armhf, for example, where the Y2038 problem still applies. Both Debian and Ubuntu performed a transition rebuilding every library (and their reverse dependencies) with -D_FILE_OFFSET_BITS=64 set where the libraries exported symbols that changed when switching to 64-bit time representation (thanks to Steve Langasek for driving this!) . Thanks to the transition most programs are ready for 2038, but interposer libraries are trickier to fix and if you maintain one it might be a good idea to check if it works well both 32-bit and 64-bit libraries. Faketime, for example is not fixed yet, see #1064555.

Select passed through environment variables with regular expressions

Firebuild filters out most of the environment variables set when starting a build to make the build more reproducible and achieve higher cache hit rate. Extra environment variables to pass through can be specified on the command line one by one, but with many similarly named variables this may become hard to maintain. With regular expressions this just became easier:

firebuild -o 'env_vars.pass_through += "MY_VARS_.*"' my_build_command

If you are not interested in acceleration just would like to explore what the build does by generating a report you can simply pass all variables:

firebuild -r -o 'env_vars.pass_through += ".*"' my_build_command Other highlights from the 0.8.3 release
  • Fixed and nicer report in Chrome and other WebKit based browsers
  • Support GLibc 2.39 by intercepting pidfd_spawn() and pidfd_spawnp()
  • Even faster Rust build acceleration

For all the changes please check out the release page on GitHub!

(This post is also published on The Firebuild blog.)

Categories: FLOSS Project Planets

Centarro: Drupal Commerce support for CPQ and product customization

Planet Drupal - Fri, 2024-12-06 16:48

Drupal Commerce is an open source eCommerce platform that natively extends Drupal to sell any type of product to anyone in the world. This includes sales of products that are customized at the point of sale, like an engraved piece of jewelry or an event registration. It also includes sales to B2B customers and others who require a configure, price, quote (CPQ) workflow to review and authorize a purchase.

This post explains the feature set at a high level with an example configuration.

Drupal's data architecture

Supporting this feature set is Drupal's data architecture, which lets the Commerce modules define new data types for entities like products, orders, order items, and more. These are defined with sets of base fields, and they can be extended further with custom fields as needed. (Read more about this subject at Drupalize.Me.)

For example, one of our merchants sells scuba equipment. While product variations include price and SKU base fields by default, this merchant added custom fields for the specifications of different models. This structured product information is then rendered to PDPs, displayed in product comparison charts, and exposed as facets in search interfaces to help customers find the right product.

When you add custom fields to an entity, you don't just get to determine where and how they are displayed but also the form interface(s) used to input field data. You can control the number of values a field supports and the type of form element used to set those values (e.g., checkboxes, select list, free tagging textfield, etc.). For data types that support multiple form modes, like order items, you can also determine the context in which a particular field will be editable by a user.

Read more
Categories: FLOSS Project Planets

FSD meeting recap 2024 12 06

FSF Blogs - Fri, 2024-12-06 15:44
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

FSF Blogs: FSD meeting recap 2024 12 06

GNU Planet! - Fri, 2024-12-06 15:44
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

Bojan Mihelac: Finding Blocks Across a Wagtail Site

Planet Python - Fri, 2024-12-06 14:37
Discover how to efficiently locate and update specific blocks across your Wagtail site, even when they're deeply nested.
Categories: FLOSS Project Planets

Pages