I'm working on a little set of scripts in python, and I came to this:
line = "a b c d e f g"
a, b, c, d, e, f, g = line.split()
I'm quite aware of the fact that these are decisions taken during implementation, but shouldn't (or does) python offer something like:
_, _, var_needed, _, _, another_var_needed, _ = line.split()
as well as Prolog does offer, in order to exclude the famous singleton variables.
I'm not sure, but wouldn't it avoid unnecessary allocation? Or creating references to the result of the split call does not count up as overhead?
EDIT:
Sorry, my point here is: in Prolog, as far as I'm concerned, in an expression like:
test(L, N) :-
test(L, 0, N).
test([], N, N).
test([_|T], M, N) :-
V is M + 1,
test(T, V, N).
The variable represented by _ is not accessible, for what I suppose the reference to the value that does exist in the list [_|T] is not even created.
But, in Python, if I use _, I can use the last value assigned to _, and also, I do suppose the assignment occurs for each of the variables _ -- which may be considered an overhead.
My question here is if shouldn't there be (or if there is) a syntax to avoid such unnecessary attributions.