02 Feb 2023

feedPlanet Python

Codementor: Roadmap to Functional Programming

roadmap to learn functional programming

02 Feb 2023 8:58am GMT

Justin Mayer: Python Development Environment on MacOS Ventura and Monterey

While installing Python and Virtualenv on MacOS Ventura and Monterey can be done several ways, this tutorial will guide you through the process of configuring a stock Mac system into a solid Python development environment.

First steps

This guide assumes that you have already installed Homebrew. For details, please follow the steps in the MacOS Configuration Guide.


We are going to install the latest version of Python via asdf and its Python plugin. Why bother, you ask, when Apple includes Python along with MacOS? Here are some reasons:

Use the following command to install asdf and Python build dependencies via Homebrew:

brew install asdf openssl readline sqlite3 xz zlib

Next we ensure asdf is loaded for both current and future shell sessions. If you are using Fish shell:

# Load asdf for this session
source (brew --prefix)/opt/asdf/asdf.fish

# Ensure asdf loads for all subsequent sessions
echo source (brew --prefix)/opt/asdf/asdf.fish >> ~/.config/fish/config.fish

# Ensure asdf doesn't disrupt activated virtual environments
echo 'if set -q VIRTUAL_ENV; source "$VIRTUAL_ENV/bin/activate.fish"; end' >> ~/.config/fish/config.fish

For Zsh (the default shell on MacOS):

. $(brew --prefix asdf)/asdf.sh
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc

Install the asdf Python plugin and the latest version of Python:

asdf plugin add python
asdf install python latest

Note the Python version number that was just installed. For the purpose of this guide, we will assume version 3.11.1, so replace that number below with the version number you actually just installed.

Set the default global Python version:

asdf global python 3.11.1

Confirm the Python version matches the latest version we just installed:

python --version


Let's say you want to install a Python package, such as the Virtualenv environment isolation tool. While many Python-related articles for MacOS tell the reader to install Virtualenv via sudo pip install virtualenv, the downsides of this method include:

  1. installs with root permissions
  2. installs into the system /Library
  3. yields a less reliable environment when using Python built with asdf

As you might have guessed by now, we are going to use the asdf Python plugin to install the Python packages that we want to be globally available. When installing via python -m pip […], packages will be installed to: ~/.asdf/installs/python/{version}/lib/python{version}/site-packages/

First, let's ensure we are using the latest version of Pip and Setuptools:

python -m pip install --upgrade pip setuptools

In the next section, we'll use Pip to install our first globally-available Python package.


Python packages installed via Pip are global in the sense that they are available across all of your projects. That can be convenient at times, but it can also create problems. For example, sometimes one project needs the latest version of Django, while another project needs an older Django version to retain compatibility with a critical third-party extension. This is one of many use cases that Virtualenv was designed to solve. On my systems, only a handful of general-purpose Python packages (including Virtualenv) are globally available - every other package is confined to virtual environments.

With that explanation behind us, let's install Virtualenv:

python -m pip install virtualenv
asdf reshim python

Create some directories to store our projects, virtual environments, and Pip configuration file, respectively:

mkdir -p ~/Projects ~/Virtualenvs ~/.config/pip

We'll then open Pip's configuration file (which may be created if it doesn't exist yet)…

vim ~/.config/pip/pip.conf

… and add some lines to it:

require-virtualenv = true

require-virtualenv = true

Now we have Virtualenv installed and ready to create new virtual environments, which we will store in ~/Virtualenvs. New virtual environments can be created via:

cd ~/Virtualenvs
virtualenv project-a

If you have both Python 3.10.x and 3.11.x installed and want to create a Python 3.10.9 virtual environment:

virtualenv -p ~/.asdf/installs/python/3.10.9/bin/python project-b

Restricting Pip to virtual environments

What happens if we think we are working in an active virtual environment, but there actually is no virtual environment active, and we install something via python -m pip install foobar? Well, in that case the foobar package gets installed into our global site-packages, defeating the purpose of our virtual environment isolation.

Thankfully, Pip has an undocumented setting (source) that tells it to bail out if there is no active virtual environment, which is exactly what we want. In fact, we've already set that above, via the require-virtualenv = true directive in Pip's configuration file. For example, let's see what happens when we try to install a package in the absence of an activated virtual environment:

python -m pip install markdown
Could not find an activated virtualenv (required).

Perfect! But once that option is set, how do we install or upgrade a global package? We can temporarily turn off this restriction by defining a new function in ~/.zshrc:

   PIP_REQUIRE_VIRTUALENV="0" python -m pip "$@"

(As usual, after adding the above you must run source ~/.zshrc for the change to take effect.)

If in the future we want to upgrade our global packages, the above function enables us to do so via:

gpip install --upgrade pip setuptools virtualenv

You could achieve the same effect via PIP_REQUIRE_VIRTUALENV="0" python -m pip install --upgrade […], but that's much more cumbersome to type every time.

Creating virtual environments

Let's create a virtual environment for Pelican, a Python-based static site generator:

cd ~/Virtualenvs
virtualenv pelican

Change to the new environment and activate it via:

cd pelican
source bin/activate

To install Pelican into the virtual environment, we'll use Pip:

python -m pip install pelican markdown

For more information about virtual environments, read the Virtualenv docs.


These are obviously just the basic steps to getting a Python development environment configured. Feel free to also check out my dotfiles.

If you found this article to be useful, feel free to find me on Twitter.

02 Feb 2023 7:00am GMT

Codementor: Hello World program in C [In series]

read previous post before jumping to this program

02 Feb 2023 5:32am GMT

feedDjango community aggregator: Community blog posts

MongoDB - Mark Smith

Support the Show

This podcast does not have any ads or sponsors. To support the show, please consider purchasing a book, signing up for Button, or reading the Django News newsletter.

02 Feb 2023 12:00am GMT

01 Feb 2023

feedDjango community aggregator: Community blog posts

Securing FastAPI with JWT Token-based Authentication

This tutorial shows how to secure a FastAPI application with JWT Token-based Authentication.

01 Feb 2023 4:28am GMT

31 Jan 2023

feedDjango community aggregator: Community blog posts

How to Install Django

This tutorial covers how to properly install the latest version of [Django (4.1)](https://www.djangoproject.com/) and [Python (3.11)](https://www.python.org). As the [official docs note](https://docs.djangoproject.com/en/dev/topics/install/), if you are already familiar with the command line, …

31 Jan 2023 8:38pm GMT

23 Jan 2023

feedPlanet Twisted

Glyph Lefkowitz: A Very Silly Program

One of the persistently lesser-known symptoms of ADHD is hyperfocus. It is sometimes quasi-accurately described as a "superpower"1 2, which it can be. In the right conditions, hyperfocus is the ability to effortlessly maintain a singular locus of attention for far longer than a neurotypical person would be able to.

However, as a general rule, it would be more accurate to characterize hyperfocus not as an "ability to focus on X" but rather as "an inability to focus on anything other than X". Sometimes hyperfocus comes on and it just digs its claws into you and won't let go until you can achieve some kind of closure.

Recently, the X I could absolutely not stop focusing on - for days at a time - was this extremely annoying picture:

chroma subsampling carnage

Which lead to me writing the silliest computer program I have written in quite some time.

You see, for some reason, macOS seems to prefer YUV422 chroma subsampling3 on external displays, even when the bitrate of the connection and selected refresh rate support RGB.4 Lots of people have been trying to address this for a literal decade5 6 7 8 9 10 11, and the problem has gotten worse with Apple Silicon, where the operating system no longer even supports the EDID-override functionality available on every other PC operating system that supports plugging in a monitor.

In brief, this means that every time I unplug my MacBook from its dock and plug it back in more than 5 minutes later, its color accuracy is destroyed and red or blue text on certain backgrounds looks like that mangled mess in the picture above. Worse, while the color distinction is definitely noticeable, it's so subtle that it's like my display is constantly gaslighting me. I can almost hear it taunting me:

Magenta? Yeah, magenta always looked like this. Maybe it's the ambient lighting in this room. You don't even have a monitor hood. Remember how you had to use one of those for print design validation? Why would you expect it to always look the same without one?

Still, I'm one of the luckier people with this problem, because I can seem to force RGB / 444 color format on my display just by leaving the display at 120Hz rather than 144, then toggling HDR on and then off again. At least I don't need to plug in the display via multiple HDMI and displayport cables and go into the OSD every time. However, there is no API to adjust, or even discover the chroma format of your connected display's link, and even the accessibility features that supposedly let you drive GUIs are broken in the system settings "Displays" panel12, so you have to do it by sending synthetic keystrokes and hoping you can tab-focus your way to the right place.

Anyway, this is a program which will be useless to anyone else as-is, but if someone else is struggling with the absolute inability to stop fiddling with the OS to try and get colors to look correct on a particular external display, by default, all the time, maybe you could do something to hack on this:

import os
from Quartz import CGDisplayRegisterReconfigurationCallback, kCGDisplaySetMainFlag, kCGDisplayBeginConfigurationFlag
from ColorSync import CGDisplayCreateUUIDFromDisplayID
from CoreFoundation import CFUUIDCreateString
from AppKit import NSApplicationMain, NSApplicationActivationPolicyAccessory, NSApplication


CGDirectDisplayID = int
CGDisplayChangeSummaryFlags = int

MY_EXTERNAL_ULTRAWIDE = '48CEABD9-3824-4674-9269-60D1696F0916'
MY_INTERNAL_DISPLAY = '37D8832A-2D66-02CA-B9F7-8F30A301B230'

def cb(display: CGDirectDisplayID, flags: CGDisplayChangeSummaryFlags, userInfo: object) -> None:
    if flags & kCGDisplayBeginConfigurationFlag:
    if flags & kCGDisplaySetMainFlag:
        displayUuid = CGDisplayCreateUUIDFromDisplayID(display)
        uuidString = CFUUIDCreateString(None, displayUuid)
        print(uuidString, "became the main display")
        if uuidString == MY_EXTERNAL_ULTRAWIDE:
            print("toggling HDR to attempt to clean up subsampling")
            print("HDR toggled.")

print("registered", CGDisplayRegisterReconfigurationCallback(cb, None))


and the linked desubsample is this atrocity, which I substantially cribbed from this helpful example:


use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

tell application "System Settings"
    delay 1
    current application's NSWorkspace's sharedWorkspace()'s openURL:(current application's NSURL's URLWithString:"x-apple.systempreferences:com.apple.Displays-Settings.extension")
    delay 0.5

    tell application "System Events"
    tell process "System Settings"
        key code 48
        key code 48
        key code 48
            delay 0.5
        key code 49
        delay 0.5
        -- activate hdr on left monitor

        set hdr to checkbox 1 of group 3 of scroll area 2 of ¬
                group 1 of group 2 of splitter group 1 of group 1 of ¬
                window "Displays"
        tell hdr
                click it
                delay 1.0
                if value is 1
                    click it
                end if
        end tell

    end tell
    end tell
end tell

This ridiculous little pair of programs does it automatically, so whenever I reconnect my MacBook to my desktop dock at home, it faffs around with clicking the HDR button for me every time. I am leaving it running in a background tmux session so - hopefully - I can finally stop thinking about this.

23 Jan 2023 3:06am GMT

18 Jan 2023

feedPlanet Twisted

Hynek Schlawack: Why I Like Nox

Ever since I got involved with open-source Python projects, tox has been vital for testing packages across Python versions (and other factors). However, lately, I've been increasingly using Nox for my projects instead. Since I've been asked why repeatedly, I'll sum up my thoughts.

18 Jan 2023 12:00pm GMT

09 Jan 2023

feedPlanet Twisted

Hynek Schlawack: Surprising Consequences of macOS’s Environment Variable Sanitization

Or: Why does DYLD_LIBRARY_PATH keep disappearing!?

09 Jan 2023 8:00am GMT

06 Dec 2022

feedPlanet Plone - Where Developers And Integrators Write

PLONE.ORG: Plone 6 RC 2 Released

Good news: the second and last release candidate of Plone 6 has arrived! The release manager for this version is Maurits van Rees (https://github.com/mauritsvanrees).

Thank you to everyone involved!

Read more about the upcoming Plone 6 and Plone 6 FAQ.


Major changes since 6.0.0rc1:

  • None really. Lots of packages have gotten a final release, losing their alpha, beta or release candidate markers.

We are in a bugfix-only mode. An upgrade from rc1 to rc2 should be painless and is recommended for everyone.

Volto frontend

The default frontend for Plone 6 is Volto. Latest release is 16.3.0 2. See the changelog 1.
Note that this is a JavaScript frontend that you need to run in a separate process with NodeJS.
The ClassicUI is still available when you only run the Python process.

Python compatibility

This release supports Python 3.8, 3.9, 3.10, and 3.11.


For installation instructions, see the documentation.
This documentation is under development, but this should get you up and running. No worries.
We expect to switch https://docs.plone.org to show the Plone 6 documentation sometime this week.

Final release date: December 12, 2022

Unless blocking issues are found that require more work, we expect to release Plone 6.0.0 final on December 12, 2022.

If you find any issues, blocking or not, please report them in the main issue tracker.

Try Plone 6!

For installation instructions, see the documentation.

See Plone 6 in action at https://6.demo.plone.org/

Read more at the community forum:

06 Dec 2022 3:45pm GMT

27 Nov 2022

feedPlanet Plone - Where Developers And Integrators Write

PLONE.ORG: Volto 16 Released - Ready for Plone 6

The Plone community is happy to announce that Volto 16 is ready and shipped! This is the final release for the upcoming Plone 6 and a major achievement from the community. Thank you everyone involved!

Volto is Plone's snappy, modern React front end powered by the RestAPI, and the default for Plone 6.

Volto 16

Volto 16 contains tons of new features, bugfixes and tweaks. Here is a sneak peak to some of them, and you can find the full release notes in GitHub: https://github.com/plone/volto/releases/tag/16.0.0

And to get the latest version go to https://github.com/plone/volto/releases/tag/16.2.0

Top features in Volto 16

  • The new Slate editor - improved inline editing and more possibilities
  • Content rules - a whole engine for automating processes based on events on the site
  • Undo - site admins can see and undo transactions
  • Bugfixes and tweaks - it is shiny and polished
  • New technology -

More feature highlights

Volto grid block

  • Added default placeholder for videos to embed them more lightly @giuliaghisini
  • Added new Block Style Wrapper. This implementation is marked as experimental during Volto 16 alpha period. The components, API and the styling are subject to change without issuing a breaking change. You can start using it in your projects and add-ons, but taking this into account. See documentation for more information. @sneridagh
  • Add default widget views for all type of fields and improve the DefaultView @ionlizarazu
  • added configurable identifier field for password reset in config.js. @giuliaghisini
  • Add expandToBackendURL helper @sneridagh
  • added 'show total results' option in Search block configuration. @giuliaghisini
  • Added viewableInBrowserObjects setting to use in alternative to downloadableObjects, if you want to view file in browser intstead downloading. @giuliaghisini
  • Disable already chosen criteria in querystring widget @kreafox
  • Added X-Forwarded-* headers to superagent requests. @mamico
  • Updated Brazilian Portuguese translation @ericof
  • Forward HTTP Range headers to the backend. @mamico
  • Add default value to color picker, if default is present in the widget schema. @sneridagh
  • Inject the classnames of the StyleWrapper into the main edit wrapper (it was wrapping directly the Edit component before). This way, the flexibility is bigger and you can act upon the whole edit container and artifacts (handlers, etc) @sneridagh
  • Refactor image block: make it schema extensible @nileshgulia1 @sneridagh
  • Add control panel via config.settings @ksuess #3426
  • Add noindex metadata tag @steffenri
  • Adding Schema for Maps Block in Sidebar @iRohitSingh
  • Add a Pluggable to the sharing page @JeffersonBledsoe #3372
  • Add listing variation schemaEnhancer to the search block schema @ionlizarazu
  • And much much more at https://github.com/plone/volto/releases/tag/16.0.0

Breaking changes Content rules demo

  • Deprecate NodeJS 12 since it's out of LTS since April 30, 2022 @sneridagh
  • Move all cypress actions to the main Makefile, providing better meaningful names. Remove them from package.json script section. @sneridagh
  • Remove div as default if as prop from RenderBlocks. Now the default is a React.Fragment instead. This could lead to CSS inconsistencies if taken this div into account, specially if used in custom add-ons without. In order to avoid them, set the as property always in your add-ons. @sneridagh
  • Removed date-fns from dependencies, this was in the build because Cypress depended on it. After the Cypress upgrade it no longer depends on it. If your project still depends on it, add it as a dependency of your project. @sneridagh
  • Removed all usage of date-fns from core. @sneridagh
  • Rename src/components/manage/Widgets/ColorPicker.jsx component to src/components/manage/Widgets/ColorPickerWidget.jsx @sneridagh
  • Remove the style wrapper around the <Block /> component in Edit mode, moved to the main edit wrapper @sneridagh
  • New cloneDeepSchema helper @sneridagh
  • Action listUsersto be called with Object. Distinguish between search for id or search for fullname, email, username @ksuess
  • Integrate volto-state add-on. @tiberiuichim @razvanMiu @eea
  • Staticize Poppins font to be compliant with EU privacy. Import from GoogleFont is disabled in site.variables. @giuliaghisini
  • Remove the callout button (the one with the megaphone icon) from the slate toolbar since it has the same styling as blockquote. If you need it anyway, you can bring it back in your addon. @sneridagh
  • Using volto-slate Headline / Subheadline buttons strips all elements in the selection @tiberiuichim
  • Use Cypress 10.3.0 (migrate from 9.x.x). Cypress 10 has some interesting goodies, being the native support of Apple Silicon Computers the main of it. See https://docs.voltocms.com/upgrade-guide/ for more information. @sneridagh
  • The complete configuration registry is passed to the add-ons and the project configuration pipeline @sneridagh
  • And much much more at https://github.com/plone/volto/releases/tag/16.0.0
See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more information about all the breaking changes.


  • Fix Search page visit crashes /contents view @dobri1408
  • Fix sidebar full size bottom opacity on edit page when sidebar is collapsed @ichim-david
  • Fix toolbar bottom opacity on edit page when toolbar is collapsed @ichim-david
  • Fix content view regression, height issue @danielamormocea
  • Fixed secure cookie option. @giuliaghisini
  • Changed addon order in addon controlpanel to mimic Classic UI @erral
  • Fixed error when loading content in a language for which a Volto translation is not available. @davisagli
  • Fix for clipped dropdown menus when the table has few or no records in Contents view @mihaislobozeanu
  • fixed view video list from youtube in Video block. @giuliaghisini
  • Fixed ICS URL in event view in seamless mode @sneridagh
  • Fix withStylingSchemaEnhancer enhancer mechanism @sneridagh
  • Add correct query parameters to the redirect @robgietema
  • Fix RenderBlocks: path @ksuess
  • Fix field id creation in dexterity control panel to have slugified id @erral
  • Changed to get intl.locale always from state @ionlizarazu
  • Fix regression, compound lang names (eg. pt-BR) no longer working @sneridagh
  • fix TokenWidget choices when editing a recently created content. @giuliaghisini
  • Fix color picker defaults implementation #2 @sneridagh
  • Enable default color in backgroundColor default StyleWrapper field which wasn't sync with the default value setting @sneridagh
  • Fix Block style wrapper: Cannot read properties of undefined (reading 'toString') @avoinea #3410
  • fix schema when content contains lock informations. @giuliaghisini
  • Don't render junk when no facets are added to the search block @tiberiuichim
  • Fix visibility of toolbar workflow dropdown for more states as fitting in .toolbar-content. @ksuess
  • Fix the video block for anonymous user @iFlameing
  • And much much more at https://github.com/plone/volto/releases/tag/16.0.0


  • Improve Cypress integration, using Cypress official Github Action. Improve some flaky tests that showed up, and were known as problematic. Refactor and rename all the Github actions giving them meaningful names, and group them by type. Enable Cypress Dashboard for Volto. @sneridagh
  • Stop using xmlrpc library for issuing the setup/teardown in core, use a cy.request instead. @sneridagh
  • Added Cypress environment variables for adjusting the backend URL of commands @JeffersonBledsoe #3271
  • Reintroduce Plone 6 acceptance tests using the latests plone.app.robotframework 2.0.0a6 specific Volto fixture. @datakurre @ericof @sneridagh
  • Upgrade all tests to use plone.app.robotframework 2.0.0a6 @sneridagh
  • Upgrade Sentry to latest version because of #3346 @sneridagh
  • Update Cypress to version 9.6.1 @sneridagh
  • Missing change from the last breaking change (Remove the style wrapper around the <Block /> component in Edit mode, moved to the main edit wrapper). Now, really move it to the main edit wrapper @sneridagh
  • Fix warning because missing key in VersionOverview component @sneridagh
  • Mock all loadable libraries. @mamico
  • And much much more at https://github.com/plone/volto/releases/tag/16.0.0


  • Move Cypress documentation from README.md to the docs. Improve the docs with the new Makefile commands.
  • Improve English grammar and syntax in backend docs. @stevepiercy
  • Fix JSX syntax highlighting. Remove duplicate heading. @stevepiercy
  • fix make task docs-linkcheckbroken if grep has exit code 1 (no lines found)
  • Updated simple.md @MdSahil-oss
  • Fix indentation in nginx configuration in simple.md @stevepiercy
  • Remove sphinx_sitemap configuration because Volto's docs are now imported into the main docs, making this setting unnecessary. @stevepiercy
  • Set the ogp_site_url to main docs, instead of training. @stevepiercy
  • aria-* attributes are now parsed correctly by jsx-lexer 2.0. @stevepiercy
  • volto-slate documentation @nileshgulia1
  • And much much more at https://github.com/plone/volto/releases/tag/16.0.0

Thank you!

We would like to thank all the people involved in creating Volto 16. Over 40 people have committed code, documentation and other effort for this. It is amazing how much we were able to accomplish as a community, during the last months.

See https://6.dev-docs.plone.org/volto/upgrade-guide/index.html for more information.

What's Next - Plone 6 final release

Where do we go from here? Plone 6! Right now, the only major feature missing were content rules and the new Slate editor, and both were included in Volto 16.

So the work is not over yet. We still need helping hands and contributors to continue the effort to make Plone 6 a reality. Everybody is welcome!

Try Plone 6 today

Feel free to try out Plone 6 with Volto 16:

27 Nov 2022 5:40pm GMT

PLONE.ORG: Plone 6 RC 1 Released

Good news: the first release candidate of Plone 6 has arrived! The release manager for this version is Maurits van Rees (https://github.com/mauritsvanrees).

Thank you to everyone involved!

Read more about the upcoming Plone 6 and Plone 6 FAQ.



Major changes since 6.0.0b3:

  • Various packages: updates to support Python 3.11. See below.

  • Zope 5.7: This feature release adds full support for Python 3.11 and a ZPublisher encoder for inputting JSON data.
    See the Zope changelog for details.

  • zc.buildout: After long development this has a final release. We use version 3.0.1, which now works nicely with latest pip (using 22.3.1).
    Note that it is usually fine if you use different versions of zc.buildout, pip, setuptools, and wheel. We just pin versions that we know work at the moment.

  • plone.restapi:

    • Added @upgrade endpoint to preview or run an upgrade of a Plone instance.

    • Added @rules endpoint with GET/POST/DELETE/PATCH.

    • Added link integrity support for slate blocks.

  • plone.scale: Add support for animated GIFs.

Volto 16 released

The default frontend for Plone 6 is Volto. Latest release is 16.2 and Volto 16 is the final release needed for Plone 6.

Python compatibility

This release supports Python 3.8, 3.9, 3.10, and 3.11.

Python 3.11.0 was released in October and we are proud to already be able to say Plone supports it! All tests pass.
This is expected to be faster than other Python versions.
Note that not all add-ons may work yet on 3.11, but in most cases the needed changes should be small.

A big thank you for this goes to the Zope part of the Plone community, especially Jens Vagelpohl and Michael Howitz.

Read more on https://plone.org/download/releases/6.0.0rc1


For installation instructions, see the documentation.
This documentation is under development, but this should get you up and running. No worries.

Help wanted

Plone 6 final needs just the final push! Wondering how you can help?

Plone 6

Plone 6 editing experience combines the robust usability of Plone with a blazingly fast JavaScript frontend

Plone 6 editor

Try Plone 6 Beta!

For installation instructions, see the documentation.

See Plone 6 in action at https://6.demo.plone.org/

Read more at the community forum:

27 Nov 2022 2:55pm GMT