You should also be aware of "contexts". In a notebook, the current context is Global`
, given by $Context
. If you want to get a list of symbols you have created, evaluate Names["Global
*"]`.
Some theory that may be helpful: there's a concept in programming of static vs. dynamic. Static things are those you can read in the source, which in this case is the notebook. Dynamic is the things that happen at runtime. When you ask "what variables have I defined in my notebook", it's a static question. If you really mean "what variables have I defined so far", it's a dynamic question. The Names
function is answering the dynamic question.
Partitioning different parts of the notebook will not be very convenient, in my estimation, but of course you can do it. Generally you can partition symbols by putting them in different contexts. You can do this by using packages (BeginPackage or Begin). But if you use the same "simple" name, like x
, in different contexts, but both contexts are on the \
$ContextPath, you'll get a shadowing error: only one `x` from one context can "win" (be the one that gets used) and the other symbol(s) will be shadowed (hidden). The one that wins, that gets used, is the one whose context comes first on the \$ContextPath. The way to resolve the ambiguity is to "fully qualify" the variable name (basically like adding a last name to differentiate two people with the same first name), like Section1`x
or Section2`x
. Usually what I would do is just use longer names.