Python Forum
Dynamic File Name to a shared folder with open command in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic File Name to a shared folder with open command in python
#7
(Jan-06-2022, 10:29 PM)DeaD_EyE Wrote: Does this work?

Oddly to me, no. I am surprised. Doubled separators as the first element of a path are supposed to be protected, but it looks like Path() destroys them.

>>> Path("//10.0.0.10", "USB_Storage")
WindowsPath('/10.0.0.10/USB_Storage')
>>> Path(r"\\10.0.0.10", "USB_Storage")
WindowsPath('/10.0.0.10/USB_Storage')
That seems like a bug to me (or I'm not setting something somewhere). If I can get past that limitation and construct the WindowsPath object directly, it should work okay. (And I have to turn the generator into a list to get the length)

>>> p = WindowsPath('//10.0.0.10/USB_Storage')
>>> print(len(list(p.glob("*"))))
87
Reply


Messages In This Thread
RE: Dynamic File Name to a shared folder with open command in python - by bowlofred - Jan-06-2022, 11:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete file with read-only permission, but write permission to parent folder cubei 6 22,449 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 1,537 Apr-24-2024, 05:47 AM
Last Post: Bronjer
Question How to add Python folder in Windows Registry ? Touktouk 1 421 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Open/save file on Android frohr 0 450 Jan-24-2024, 06:28 PM
Last Post: frohr
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 745 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  file open "file not found error" shanoger 8 1,567 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Reading a file name fron a folder on my desktop Fiona 4 1,107 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  How can i combine these two functions so i only open the file once? cubangt 4 1,089 Aug-14-2023, 05:04 PM
Last Post: snippsat
  how do I open two instances of visual studio code with the same folder? SuchUmami 3 1,115 Jun-26-2023, 09:40 AM
Last Post: snippsat
  I cannot able open a file in python ? ted 5 4,020 Feb-11-2023, 02:38 AM
Last Post: ted

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020