Maestro Stefano, questo sembra bellissimo! :-)
On 14.10.20 16:13, Stefano Miccoli via Owfs-developers wrote:
> A more succinct way would be:
>
> str(x).encode()
>
> In fact the outer call to ‘bytes’ in 'bytes(str.encode(str(x)))' is a
> no-op, and python strings are objects which have an ‘encode'
Thanks Stefano, that looks much better.
On 14/10/2020 15:13, Stefano Miccoli via Owfs-developers wrote:
A more succinct way would be:
str(x).encode()
In fact the outer call to ‘bytes’ in 'bytes(str.encode(str(x)))' is a
no-op, and python strings are objects which have an ‘encode' method,
so
A more succinct way would be:
str(x).encode()
In fact the outer call to ‘bytes’ in 'bytes(str.encode(str(x)))' is a no-op,
and python strings are objects which have an ‘encode' method, so no need call
the class method ’str.encode’.
Another possible way is
f"{x:d}".encode()
or
"{:d}".forma
I had a bit of trouble with this and thought it worth sharing the solution.
With Python2 and pyownet I could use
owp.write('/settings/timeout/directory', 60)
but with Python3 that throws an error, TypeError: 'data' argument must
be binary. I can use
owp.write('/settings/timeout/dire