[issue12740] Add struct.Struct.nmemb

2013-07-11 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: rhettinger -> versions: +Python 3.4 -Python 3.3 ___ Python tracker ___ ___ Python-bugs-li

[issue12740] Add struct.Struct.nmemb

2011-08-16 Thread Meador Inge
Meador Inge added the comment: Stefan, it is a constructed failure (I hacked the unit test to break it). -- ___ Python tracker ___ __

[issue12740] Add struct.Struct.nmemb

2011-08-16 Thread Stefan Krah
Stefan Krah added the comment: Including the format string in the error output is a good idea. Meador, was this a constructed failure to show the output or did it really occur? -- ___ Python tracker __

[issue12740] Add struct.Struct.nmemb

2011-08-15 Thread Meador Inge
Meador Inge added the comment: On Sun, Aug 14, 2011 at 1:03 PM, Stefan Krah wrote: > > Stefan Krah added the comment: > > I like random tests in the stdlib, otherwise the same thing gets tested > over and over again. `make buildbottest` prints the seed, and you can do > it for a single test as

[issue12740] Add struct.Struct.nmemb

2011-08-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: In general, I think we can prevent confusion about the meaning of __len__ by sticking to the general rule: len(object)==len(list(obj)) for anything that produces an iterable result. In the case of struct, that would be the length of the tuple returned by

[issue12740] Add struct.Struct.nmemb

2011-08-14 Thread Stefan Krah
Stefan Krah added the comment: Just to throw in a new name: Struct.nitems would also be possible. -- ___ Python tracker ___ ___ Pytho

[issue12740] Add struct.Struct.nmemb

2011-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > It looks like the choice is between s.nmembers and len(s). I thought > about len(s), but since Struct.pack() returns a bytes object, this > might be confusing. I agree there's a risk of confusion between len()-number-of-elements and size()-number-of-bytes. We

[issue12740] Add struct.Struct.nmemb

2011-08-14 Thread Stefan Krah
Stefan Krah added the comment: I like random tests in the stdlib, otherwise the same thing gets tested over and over again. `make buildbottest` prints the seed, and you can do it for a single test as well: $ ./python -m test -r test_heapq Using random seed 5857004 [1/1] test_heapq 1 test OK.

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger priority: normal -> low ___ Python tracker ___ ___ Python-bugs-list mailing

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread Meador Inge
Meador Inge added the comment: The functionality part of the patch looks reasonable. However, the pseudo-randomization in the unit tests seems like a bad idea. Say someone is adding a new feature X. Runs the unit tests to find one of them failing. Then runs them again to investigate and t

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread Raymond Hettinger
Raymond Hettinger added the comment: How about __len__()? -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread Georg Brandl
Georg Brandl added the comment: While we're at it, let's add str.pbrk() ;) -- nosy: +georg.brandl ___ Python tracker ___ ___ Python-b

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: I had never heard of "nmemb". "nmembers" would be less cryptic. The patch needs a "versionadded" directive in the docs. -- nosy: +pitrou ___ Python tracker ___

[issue12740] Add struct.Struct.nmemb

2011-08-13 Thread R. David Murray
R. David Murray added the comment: As a new feature, this could only go into 3.3. -- nosy: +r.david.murray versions: -Python 3.2 ___ Python tracker ___

[issue12740] Add struct.Struct.nmemb

2011-08-12 Thread Stefan Krah
New submission from Stefan Krah : It is somewhat complicated to calculate the number of members in a Struct, so I propose to add Struct.nmemb (in 3.3, 3.2 and 2.7): >>> import struct >>> s = struct.Struct("Pxx3L3s") >>> s.size 47 >>> s.nmemb 5 I chose 'nmemb' because it is a standard name