On Fri, Nov 5, 2021 at 2:59 AM Jonathan Goble <jcgob...@gmail.com> wrote: > > On Thu, Nov 4, 2021 at 10:37 AM Eric Fahlgren <ericfahlg...@gmail.com> wrote: >> >> On Thu, Nov 4, 2021 at 12:01 AM Ethan Furman <et...@stoneleaf.us> wrote: >>> >>> >>> bytearray.fromsize(5, fill=b'\x0a') >>> bytearray(b'\x0a\x0a\x0a\x0a\x0a') >> >> >> What happens if you supply more than one byte for the fill argument? Silent >> truncation, raise ValueError('too long') or ??? > > > It would seem reasonable to me for a multi-byte sequence to be filled as-is > in a repeating pattern, perhaps truncating the last repetition if len(fill) > is not an even multiple of the size. At least that's the intuitive behavior > for me. > > That said, I don't know if such behavior would be useful in practice (i.e. > whether there's a use case for it). >
It's definitely useful behaviour, but aligns better with sequence multiplication than a fill= constructor parameter. My expectation (or if you prefer: my preferred shed colour) would be ValueError. ChrisA _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/R35YPY4TRHMGDBELZTO25Z2UZBAEB7IC/ Code of Conduct: http://python.org/psf/codeofconduct/