From df388070a17e323eadad0dc58ad4c9e2705b7718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 13 Oct 2024 20:58:14 +0200 Subject: [PATCH] Match statement --- README.md | 2 +- index.html | 2 +- parse.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 868f7583..4c00a28c 100644 --- a/README.md +++ b/README.md @@ -2231,7 +2231,7 @@ match : >>> match Path('/home/gto/python-cheatsheet/README.md'): ... case Path( ... parts=['/', 'home', user, *_] -... ) as p if p.stem.lower() == 'readme' and p.suffix.lower() in ['.md', '.txt']: +... ) as p if p.name.lower().startswith('readme') and p.is_file(): ... print(f'{p.name} is a readme file that belongs to user {user}.') 'README.md is a readme file that belongs to user gto.' ``` diff --git a/index.html b/index.html index 480394b3..a534d910 100644 --- a/index.html +++ b/index.html @@ -1827,7 +1827,7 @@

Format

>>> match Path('/home/gto/python-cheatsheet/README.md'): ... case Path( ... parts=['/', 'home', user, *_] -... ) as p if p.stem.lower() == 'readme' and p.suffix.lower() in ['.md', '.txt']: +... ) as p if p.name.lower().startswith('readme') and p.is_file(): ... print(f'{p.name} is a readme file that belongs to user {user}.') 'README.md is a readme file that belongs to user gto.'

diff --git a/parse.js b/parse.js index 7dc0e157..90f870ad 100755 --- a/parse.js +++ b/parse.js @@ -113,7 +113,7 @@ const MATCH_EXAMPLE = '>>> match Path(\'/home/gto/python-cheatsheet/README.md\'):\n' + '... case Path(\n' + '... parts=[\'/\', \'home\', user, *_]\n' + - '... ) as p if p.stem.lower() == \'readme\' and p.suffix.lower() in [\'.md\', \'.txt\']:\n' + + '... ) as p if p.name.lower().startswith(\'readme\') and p.is_file():\n' + '... print(f\'{p.name} is a readme file that belongs to user {user}.\')\n' + '\'README.md is a readme file that belongs to user gto.\'\n';