Deutsch   English   Français   Italiano  
<6194c003$0$20251$426a74cc@news.free.fr>

View for Bookmarking (what is this?)
Look up another Usenet article

X-Received: by 2002:a05:6000:1a8b:: with SMTP id f11mr17367657wry.409.1637138435235;
        Wed, 17 Nov 2021 00:40:35 -0800 (PST)
Path: ...!news-out.google.com!nntp.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Date: Wed, 17 Nov 2021 09:40:33 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101
 Thunderbird/91.3.1
Newsgroups: fr.comp.lang.python
From: ast <ast@invalid>
Subject: Liens symboliques sous Windows
Lines: 40
Message-ID: <6194c003$0$20251$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 17 Nov 2021 09:40:35 CET
NNTP-Posting-Host: 91.170.32.5
X-Trace: 1637138435 news-1.free.fr 20251 91.170.32.5:14253
X-Complaints-To: abuse@proxad.net
Content-Language: fr
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Bytes: 1571

Bonjour

Il me semble que les liens symboliques de Windows ne sont
pas bien reconnus par les modules os et pathlib.
Voyez:

 >>> from pathlib import Path

 >>> p2 = Path('C:/Users/jm/desktop/json.txt - Raccourci.lnk')

 >>> p2
WindowsPath('C:/Users/jm/desktop/json.txt - Raccourci.lnk')

 >>> p2.exists()
True

 >>> p2.is_file()
True

 >>> p2.is_symlink()
False


Sur cette dernière commande, j'attendais True et pour le
p2.is_file j'attendais plutôt False


Avec la lib os, c'est pareil

import os

 >>> os.path.exists(p2)
True

 >>> os.path.isfile(p2)
True

os.path.islink(p2)
False