Skip to contentSkip to conversation

more nitpickery: difference between d.getVar() and d.expand()?

DISCUSSION Robert P. J. Day 2 participants 2 messages May 5, 2020 – May 19, 2020

lore
Share & tools
lore
#0 lore raw

no, wait, hear me out :-). still crawling through BB user manual,
section 3.5.2, talks about using d.getVar("X") "or for more complicated expressions, use d.expand()".

fair enough, but it seems like a lot of the code bounces back and
forth when getting the value of a simple variable, as in:

  libdir = d.getVar("libdir")
  libdir = d.expand("${libdir}")

given that d.getVar() by default expands the value, is there some difference between the two statements above when specifically accessing a single variable in the data dictionary?

rday

#1 lore raw
Quoted 7 lines · Robert P. J. Day

no, wait, hear me out :-). still crawling through BB user manual,
section 3.5.2, talks about using d.getVar("X") "or for more complicated expressions, use d.expand()".

fair enough, but it seems like a lot of the code bounces back and
forth when getting the value of a simple variable, as in:

Quoted 6 lines
  libdir = d.getVar("libdir")
  libdir = d.expand("${libdir}")

given that d.getVar() by default expands the value, is there some difference between the two statements above when specifically accessing a single variable in the data dictionary?

No, there is no difference. I'd usually suggest getVar for a single variable and expand for an expression.

Cheers,

Richard