diff --git a/README.md b/README.md index 868f758..4c00a28 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 480394b..a534d91 100644 --- a/index.html +++ b/index.html @@ -1827,7 +1827,7 @@ first_element = op.methodcaller('pop', >>> 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 7dc0e15..90f870a 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';