[issue12740] Add struct.Struct.nmemb
Stefan Krah
report at bugs.python.org
Sun Aug 14 20:03:56 CEST 2011
Stefan Krah <stefan-usenet at bytereef.org> 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.
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.
Struct.arity may be another option. This also reflects that pack()
will be an n-ary function for the given format string (and that
Struct is a packing object, not really a struct itself).
Still, probably I'm +0.5 on 'nmembers' compared to the other options.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12740>
_______________________________________
More information about the Python-bugs-list
mailing list