Namelist variable stays as single int/float value with comma
ehdez opened this issue · 2 comments
Taking a look at a sample namelist:
&aaa
abc = 1,
xyz = 2,
I would expect the variables abc
and xyz
to be output as python lists with single elements like so:
abc = [1]
and xyz = [2]
but they end up as abc = 1
and xyz = 2
. Is there no point on adding a comma at end of line to these variables? Is this intended? if so, what is the correct syntax to denote single value lists?
I'm afraid that this is the correct behavior. The comma is only a separator, and doesn't have the same syntactic meaning as in Python.
This is the dilemma with parsing namelists: there is no way to know if abc
should be a scalar or a vector of one element. The actual parsing tries to be as agnostic as possible, but at the end of the day, it's going to presume that it's a scalar.
You may have better luck with something like this:
&aaa
abc(1) = 1,
xyz(1) = 2,
/
I see, thanks for the prompt reply!