Python Walrus Operator

Posted on Wed 06 December 2023 in TIL • Tagged with Python

Today I learned that in Python 3.8 they added the walrus operator.

:=

This docile creature lets you do this:

if m := re.search('(\d+) inch tusks',line):
    print(f'length: {m.group(1)}')

This was badly needed.

I think I need to read all the Python 3.x "whatsnew …


Continue reading

Notifying users of processes killed by the in-kernel OOM killer

Posted on Wed 31 August 2022 in Sysadmin • Tagged with oom, python, hacks

Updates:

  • 2023-05-01: Moved code to GitLab. Corrections to reflect how new version works.
  • 2022-09-09: Updated script to add Bcc option.

We've got servers with up to 512GB of RAM. And we've got users who periodically use it all up. Then their process gets killed by the kernel and the user …


Continue reading