Re: [Python-ideas] pathlib suggestions

2017-01-26 Thread Philipp A.
How about adding a new argument to with_suffix? Path.with_suffix(suffix: str, stripped: Union[int, str, Iterable[str]]=1) stripped would either receive an int (in which case it will greedily strip up to that many suffixes), or a (optionally compound) suffix which would be strippe

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Franklin? Lee
> A ".tar.gz" is not the same as a ".svg.gz". The fact that they are both > gzip-compressed is an implementation detail as far as most software I deal > with is concerned. My unarchiver will extract a ".tar.gz" into a directory > as if it was just a ".tar", while my image viewer will view a ".svg

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 11:16 AM, Petr Viktorin wrote: > On 01/25/2017 04:33 PM, Todd wrote: > >> On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin > > wrote: >> >> On 01/25/2017 04:04 PM, Todd wrote: >> >> On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Steve Dower
On 25Jan2017 0816, Petr Viktorin wrote: On 01/25/2017 04:33 PM, Todd wrote: But what if the .tar.gz file is called "spam-4.2.5-final.tar.gz"? Existing tools like glob and endswith() can deal with the ".tar.gz" extension reliably, but "fullsuffix" would, arguably, not give the ans

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Petr Viktorin
On 01/25/2017 04:33 PM, Todd wrote: On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin mailto:encu...@gmail.com>> wrote: On 01/25/2017 04:04 PM, Todd wrote: On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull mailto:turnbull.stephen...@u.tsukuba.ac.jp>

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 11:04 AM, Thomas Kluyver wrote: > On Wed, Jan 25, 2017, at 03:54 PM, Todd wrote: > > Those [.tar.foo] are just examples that I encounter a lot, there can be > other cases where multiple extensions are used. > > > The real issue is that there's no definition of what an exte

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Thomas Kluyver
On Wed, Jan 25, 2017, at 03:58 PM, Todd wrote: > On Wed, Jan 25, 2017 at 10:45 AM, Thomas Kluyver > wrote: >> __You might not, but it seems like an attractive nuisance. You can't >> reliably use it as a test for .tar.gz files, but it would be easy to >> think that you can and write buggy code us

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Paul Moore
On 25 January 2017 at 16:04, Thomas Kluyver wrote: > On Wed, Jan 25, 2017, at 03:54 PM, Todd wrote: > > Those [.tar.foo] are just examples that I encounter a lot, there can be > other cases where multiple extensions are used. > > > The real issue is that there's no definition of what an extension

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Thomas Kluyver
On Wed, Jan 25, 2017, at 03:54 PM, Todd wrote: > Those [.tar.foo] are just examples that I encounter a lot, there can > be other cases where multiple extensions are used. The real issue is that there's no definition of what an extension is. You can have dots anywhere in a filename, and it's not

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 10:45 AM, Stephan Houben wrote: > Hi all, > > It seems to me that the correct algorithm to get the "full suffix" is not > to take everything after the FIRST dot, > but rather to: > 1. Recognize that the last suffix is one of the UNIX-style compression > tools .Z, .gz, ,bz2

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 10:45 AM, Thomas Kluyver wrote: > On Wed, Jan 25, 2017, at 03:33 PM, Todd wrote: > > On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin wrote: > > But what if the .tar.gz file is called "spam-4.2.5-final.tar.gz"? > Existing tools like glob and endswith() can deal with the ".

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Stephan Houben
Hi all, It seems to me that the correct algorithm to get the "full suffix" is not to take everything after the FIRST dot, but rather to: 1. Recognize that the last suffix is one of the UNIX-style compression tools .Z, .gz, ,bz2, .xz, .lzma (at least) 2. Then add the next-to-last suffix. So we can

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Thomas Kluyver
On Wed, Jan 25, 2017, at 03:33 PM, Todd wrote: > On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin > wrote: >> But what if the .tar.gz file is called "spam-4.2.5-final.tar.gz"? >> Existing tools like glob and endswith() can deal with the ".tar.gz" >> extension reliably, but "fullsuffix" would, a

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 10:18 AM, Petr Viktorin wrote: > On 01/25/2017 04:04 PM, Todd wrote: > >> On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull >> > > wrote: >> >> I'm just going to let fly with the +1s and -1s, don't take them too >> se

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Petr Viktorin
On 01/25/2017 04:04 PM, Todd wrote: On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull mailto:turnbull.stephen...@u.tsukuba.ac.jp>> wrote: I'm just going to let fly with the +1s and -1s, don't take them too seriously, they're basically impressionistic (I'm not a huge user of pathl

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Todd
On Wed, Jan 25, 2017 at 12:25 AM, Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > I'm just going to let fly with the +1s and -1s, don't take them too > seriously, they're basically impressionistic (I'm not a huge user of > pathlib yet). > > Todd writes: > > > So although the n

Re: [Python-ideas] pathlib suggestions

2017-01-25 Thread Ed Kellett
On Wed, 25 Jan 2017 at 05:26 Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > -1 I don't see how this is an improvement. If it would raise if > exist_ok == False, then > > try: > p.rename(another_p, exist_ok=False) > except ExistNotOKError: >

[Python-ideas] pathlib suggestions

2017-01-24 Thread Stephen J. Turnbull
I'm just going to let fly with the +1s and -1s, don't take them too seriously, they're basically impressionistic (I'm not a huge user of pathlib yet). Todd writes: > So although the names are tentative, perhaps there could be a "fullsuffix" > property to return the extensions as a single string

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Vamsi Krishna Avula
017 3:32:14 AM To: python-ideas Subject: Re: [Python-ideas] pathlib suggestions On Tue, Jan 24, 2017 at 4:27 PM, Chris Angelico mailto:ros...@gmail.com>> wrote: On Wed, Jan 25, 2017 at 7:30 AM, Todd mailto:toddr...@gmail.com>> wrote: > First, for me, extensions are primarily use

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Todd
On Tue, Jan 24, 2017 at 4:27 PM, Chris Angelico wrote: > On Wed, Jan 25, 2017 at 7:30 AM, Todd wrote: > > First, for me, extensions are primarily useful as a single unit. So, > > practically speaking, the extension of "spam.tar.gz" isn't ".gz", it is > > ".tar.gz". So it would be nice to have

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Chris Angelico
On Wed, Jan 25, 2017 at 7:30 AM, Todd wrote: > First, for me, extensions are primarily useful as a single unit. So, > practically speaking, the extension of "spam.tar.gz" isn't ".gz", it is > ".tar.gz". So it would be nice to have some properties to make it easier to > deal with the "complete" e

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Ryan Gonzalez
As another suggestion, I'd love an rmtree method analogous to shutil.rmtree. And maybe also a remove method, that basically does: if path.is_dir(): path.rmtree() else: path.unlink() \-- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone

[Python-ideas] pathlib suggestions

2017-01-24 Thread Todd
I have been using pathlib, and I have come up with a few suggestions on what would make the module more useful for me (and hopefully others): First, for me, extensions are primarily useful as a single unit. So, practically speaking, the extension of "spam.tar.gz" isn't ".gz", it is ".tar.gz". So