lyx2lyx: many unused variables (any bugs?)
José Matos
jaomatos at gmail.com
Thu Dec 8 21:06:30 UTC 2022
On Thu, 2022-12-08 at 21:37 +0100, Thibaut Cuvelier wrote:
> The Python standard for variables that are introduced just because
> the syntax requires it (like iterating X times) is to name that
> variable _ (or to prefix it with an underscore if there are more than
> one).
Yes, that would also be my suggestion. The same applies if you define a
function that needs to accept two arguments (as part of some API) but
that you will not use one of them:
def fun(a,_):
print(a)
This ensures that you still need to add the second argument but it also
signals that the arguments will not be used.
On the same vein for 2.5 I intend to start, in an iterative process, to
add type hinting to our python code: http://mypy-lang.org/
One example:
def fib(n):
if n==0 or n==1:
return 1
else:
return fin(n-1)+fib(n-2)
becomes
def fib(n: int) -> int:
if n==0 or n==1:
return 1
else:
return fin(n-1)+fib(n-2)
The code works the same in both cases but we can use static type
checking to ensure that functions are called as intended.
This checking is not done at running time. Instead it can be run in a
test stage, like pylint that Scott suggests.
--
José Abílio
More information about the lyx-devel
mailing list