Calling `du` is possible but I prefer to avoid these kinds of solutions.
(OS-specific, parsing text output from a third-party program.)
On Wed, May 3, 2017 at 1:57 AM, Cameron Simpson wrote:
> On 02May2017 22:07, Ram Rachum wrote:
>
>> I have a suggestion: Add a function shutil.get_dir_size tha
Steven D'Aprano wrote:
I've also been thinking about generalisations such as grouping lines
into paragraphs, words into lines, etc.
You're probably going to want considerably more complicated
algorithms for that kind of thing, though. Let's keep it
simple.
--
Greg
On 02.05.17 22:07, Ram Rachum wrote:
I have a suggestion: Add a function shutil.get_dir_size that gets the
size of a directory, including all the items inside it recursively. I
currently need this functionality and it looks like I'll have to write
my own function for it.
The comprehensive imple
On 03/05/17 01:43, Steven D'Aprano wrote:
On Tue, May 02, 2017 at 11:39:48PM +0100, Erik wrote:
On 02/05/17 12:31, Steven D'Aprano wrote:
Rather than duplicate the API and logic everywhere, I suggest we add a
new string method. My suggestion is str.chunk(size, delimiter=' ') and
str.rchunk()
On Tue, May 2, 2017 at 8:43 PM, Steven D'Aprano wrote:
> String methods should return strings.
>
>>> "A-B-C".split("-")
['A', 'B', 'C']
If chunk() worked for all iterables:
>>> " ".join("1234ABCDEF".chunk(4))
"1234 ABCD EF"
Cheers,
--
Juancarlo *Añez*
On Tue, May 02, 2017 at 11:39:48PM +0100, Erik wrote:
> On 02/05/17 12:31, Steven D'Aprano wrote:
> >Rather than duplicate the API and logic everywhere, I suggest we add a
> >new string method. My suggestion is str.chunk(size, delimiter=' ') and
> >str.rchunk() with the same arguments:
For the re
On 02May2017 22:07, Ram Rachum wrote:
I have a suggestion: Add a function shutil.get_dir_size that gets the size
of a directory, including all the items inside it recursively. I currently
need this functionality and it looks like I'll have to write my own
function for it.
Feels like a rather n
On Tue, May 02, 2017 at 10:48:08AM -0700, David Mertz wrote:
> Maybe your API is for any length tuple, with the final element repeated.
> So I guess maybe this example could be:
>
> "0113225551212".rchunk((2,2,3,1,2,3),'-')
That's what I meant.
--
Steve
___
On 26/04/17 21:50, Chris Angelico wrote:
On Thu, Apr 27, 2017 at 6:24 AM, Erik wrote:
The background is that what I find myself doing a lot of for private
projects is importing data from databases into a structured collection of
objects and then grouping and analyzing the data in different ways
On 02/05/17 12:31, Steven D'Aprano wrote:
I disagree with this approach. There's nothing special about bytes.hex()
here, perhaps we want to format the output of hex() or bin() or oct(),
or for that matter "%x" and any of the other string templates?
In fact, this is a string operation that could
For a name, I think "group" would be better than "chunk".
We talk about grouping the digits of a number, not chunking
them.
--
Greg
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Cond
Hi,
I have a suggestion: Add a function shutil.get_dir_size that gets the size
of a directory, including all the items inside it recursively. I currently
need this functionality and it looks like I'll have to write my own
function for it.
Cheers,
Ram.
The main reason for naming it `delimit` was to be consistent with the karg
`delimiter`, so `str.delimit(index, delimiter)`. You could call it `chop` I
guess, but I'm just bikeshedding, so will leave it while you guys figure
out the important stuff.
-- Carl Smith
carl.in...@gmail.com
On 2 May 2017
On Tue, May 2, 2017 at 4:31 AM, Steven D'Aprano wrote:
> Rather than duplicate the API and logic everywhere, I suggest we add a
> new string method. My suggestion is str.chunk(size, delimiter=' ') and
> str.rchunk() with the same arguments:
>
> "1234ABCDEF".chunk(4)
> => returns "1234 ABCD EF"
>
On Tue, May 02, 2017 at 11:45:35PM +1000, Nick Coghlan wrote:
> Attempting to align the terminology with existing string methods and
> other stdlib APIs:
[...]
> 1. we don't have any current APIs or documentation that use "chunk" in
> combination with any kind of delimiter
> 2. we don't have any c
On 2 May 2017 at 22:10, wrote:
> Steven D’Aprano was giving me an idea (in the bytes.hex delimiter
> discussion):
>
> I had very often the use case that I want to split sequences into
> subsequences of same size.
>
> How about adding a chunks() and rchunks() function to sequences:
>
> [1,2,3,4,5,
On 2 May 2017 at 21:31, Steven D'Aprano wrote:
> On Mon, May 01, 2017 at 11:38:20PM +1000, Nick Coghlan wrote:
>> However, a much simpler alternative would be to just support two
>> keyword arguments to hex(): "delimiter" (as you suggest) and
>> "chunk_size" (defaulting to 1, so you get per-byte c
On Tue, May 2, 2017 at 8:10 AM wrote:
> Steven D’Aprano was giving me an idea (in the bytes.hex delimiter
> discussion):
>
>
>
> I had very often the use case that I want to split sequences into
> subsequences of same size.
>
> How about adding a chunks() and rchunks() function to sequences:
>
>
On the block size arg, couldn't it just be named `index`?
On Tue, 2 May 2017 13:12 Carl Smith, wrote:
> Sorry. I meant to be terse, but wasn't clear enough. I meant the method
> name. If it takes a `delimiter` karg, it would be consistent to call the
> operation `delimit`.
>
> On Tue, 2 May 2017
Sorry. I meant to be terse, but wasn't clear enough. I meant the method
name. If it takes a `delimiter` karg, it would be consistent to call the
operation `delimit`.
On Tue, 2 May 2017 13:06 Carl Smith, wrote:
> Couldn't it just be named `str.delimit`? I totally agree with Steve for
> what it's
Steven D’Aprano was giving me an idea (in the bytes.hex delimiter discussion):
I had very often the use case that I want to split sequences into subsequences
of same size.
How about adding a chunks() and rchunks() function to sequences:
[1,2,3,4,5,6,7].chunks(3) => [[1,2,3], [4,5,6], [7]]
"1234“
Couldn't it just be named `str.delimit`? I totally agree with Steve for
what it's worth. Thanks for everything guys. Best,
On Tue, 2 May 2017 13:02 Joao S. O. Bueno, wrote:
> On 1 May 2017 at 11:04, Juancarlo Añez wrote:
> >
> > On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
> >>
> >> jus
On 1 May 2017 at 11:04, Juancarlo Añez wrote:
>
> On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
>>
>> just support two
>> keyword arguments to hex(): "delimiter" (as you suggest) and
>> "chunk_size" (defaulting to 1, so you get per-byte chunking by
>> default)
>
>
> I'd expect "chunk_size"
On Mon, May 01, 2017 at 11:38:20PM +1000, Nick Coghlan wrote:
> We're definitely open to offering better formatting options for bytes.hex().
>
> My proposal in https://bugs.python.org/issue22385 was to define a new
> formatting mini-language (akin to the way strftime works, but with a
> much simp
On 2017-05-01 11:50, Jerry Hill wrote:
>What happens if you use this syntax in a top-level function rather
>than a method? (Or a static method?)
>
>def function(x, y, x.attr):
> ...
>
>(And don't forget that behind the scenes, methods*are* functions.) What
>would this syntax even mean?
It w
25 matches
Mail list logo