specification for struct.unpack_from()
at https://docs.python.org/3/library/struct.html the entry struct.unpack_from(format, /, buffer, offset=0) should probably instead be struct.unpack_from(format, buffer, offset=0) ciao!
Hi Christopher, Le 2021-04-18 à 23:43, Christopher Sylvain a écrit :
the entry struct.unpack_from(format, /, buffer, offset=0)
should probably instead be struct.unpack_from(format, buffer, offset=0)
Thanks for your time to report this issue! Appreciated. This slash is the syntax for positional-only parameters [1], the paramters on the left side of the slash can only be given by position (not by name), which is the case here, see:
unpack_from(format="c", buffer=b"a", offset=0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unpack_from() takes at least 1 positional argument (0 given)
So I see no error here, if I missed something, don't hesitate to tell me. [1]: https://docs.python.org/3/glossary.html#positional-only-parameter -- [Julien Palard](https://mdk.fr)
ah! well, for all my python documentation reading, this is the first i have
encountered this!
then, perhaps, the "bug" is this special indication is not obvious enough?
it is a quite important to understanding the definition in
struct.unpack_from(), but no special reference is made.
thanks for writing back!
On Tue, Apr 20, 2021 at 9:09 AM Julien Palard
Hi Christopher,
Le 2021-04-18 à 23:43, Christopher Sylvain a écrit :
the entry struct.unpack_from(format, /, buffer, offset=0)
should probably instead be struct.unpack_from(format, buffer, offset=0)
Thanks for your time to report this issue! Appreciated.
This slash is the syntax for positional-only parameters [1], the paramters on the left side of the slash can only be given by position (not by name), which is the case here, see:
unpack_from(format="c", buffer=b"a", offset=0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unpack_from() takes at least 1 positional argument (0 given)
So I see no error here, if I missed something, don't hesitate to tell me.
[1]: https://docs.python.org/3/glossary.html#positional-only-parameter -- [Julien Palard](https://mdk.fr)
participants (2)
-
Christopher Sylvain
-
Julien Palard